10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Handling Database ErrorsFor example, your error handling procedure might use inquire_sql to determineif a transaction is open:procedure error_handler(...) =begin...inquire_sql (in_xact = transaction);if in_xact = FALSE then...end;Choosing an Error Handling StrategyThis section discusses some common strategies for detecting and handlingDBMS errors. These include:• Using the DBMSErrorPrinting attribute• Calling a general error-handling procedure• Detecting errors when manipulating BitmapObject and StringObject objectsFor a discussion of strategies for detecting and handling DBMS errors inDataStream objects, see How You Can Handle DataStream Errors (seepage 199).How You Can Use the DBMSErrorPrinting AttributeAnother method of handling errors is to call a general error-handling procedureeach time an error is detected. For example, the script for the check_out framein the Videos application calls an error handling procedure after each databasestatement to detect and handle any DBMS errors. The following code fragmentfrom the check_out frame script calls the error handler:/* Update video information */update v_videoset last_checkout =:checkout_form.checkout[i].date_out,no_checkouts = no_checkouts + 1where vid_no = :checkout_form.checkout[i].vid_no;if error_handler(frm = CurFrame, commit_evt ='Commit')!= ER_OK thenresume;endif;...202 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!