10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Handling Database ErrorsThe if statement in the example calls the error-handling procedure. Thisprocedure first checks to see if there was a DBMS error. If none occurred, itreturns ER_OK to the calling program. If an error occurred and the error wasnot a deadlock error, then the routine displays an error message that includesthe generic and local DBMS error number. If the error was a deadlock, theprocedure sends an event back to the application to retry the DBMS statement.The following code is the error handling procedure:/*** Name: error_handler -- Detects and handles DBMS** errors.**** Description:** This procedure first checks if an error occurred** in the previous DBMS statement. If so, it pops up** an error message. If the error was deadlock or** another error for which retry is appropriate, it** sends an event back to the calling** frame to retry the DBMS statement.** No need to roll back the transaction in either** case because the main_control frame set the** application's database session to roll back** automatically for all DBMS errors.**** Called By:** check_out frame.**** Parameters:** frm Frame which called this procedure.** commit_evt Event sent to calling frame when** there is a deadlock to retry DBMS** statements.**** Returns:** DBSession.ErrorNumber set by previous DBMS** statement;** ER_OK (0) if success*/procedure error_handler(frm = FrameExec, /* Calling frame */commit_evt = varchar(32), /* Commit event for** retries if** a deadlock** occurred. */) =declareerr_no = integer not null /* Error number */enddeclareWorking with a Database 203

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!