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 Errorsbeginerr_no = CurProcedure.DBSession.ErrorNumber;if err_no = 49000 then/* We have encountered a deadlock or log** full. */message 'Deadlock error occurred whileupdating the database.';frm.SendUserEvent(commit_evt);elseif err_no != ER_OK thenmessage 'Error occurred while making changesin the database.' +dbms_error_message();endif;return err_no;end;Note: The error-handling procedure calls another procedure,dbms_error_message, when a non-deadlock DBMS error occurs. This calledprocedure returns the generic and local error numbers. For the code for thedbms_error_message procedure, see How You Can Use the ErrorNumber andDBMSError Attributes (see page 198).How You Can Detect Errors When Working with Bitmaps, String, Long VChar, and Long ByteObjectsHow you handle errors when you manipulate bitmaps, long byte, long varchar,or string objects depends on how you have stored these objects and whatoperations you are performing.For example, if your bitmaps, long byte, long varchar, or string objects arestored in a file, whenever you use the WriteToFile method you can check themethod's return value to detect errors. The WriteToFile method returns 0 if itwas successful or a 1 if not.If your bitmaps and string objects are stored in the database, use theInsertIntoDB, UpdateInDB, and DeleteFromDB methods to manipulate theseobjects in the database. If your long byte and long varchar objects are storedin the database, use the FetchFromDB or UpdateInDB methods to manipulatethese objects in the database. When you do, your error checking should checknot only the return status of the method but also the value ofDBSessionObject's ErrorNumber attribute because these methods access thedatabase, and it is possible for a DBMS error to occur.Finally, you can set a FileHandle or DBHandle directly, for example, by anassignment statement. When you do so, you can check the ErrorStatusattribute for errors. For more information about this attribute, see How YouCan Use the ErrorStatus Attribute (see page 201).204 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!