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.

How You Can Access a Database with Standard SQL StatementsThe following statement provides an example of closing a cursor:close cust_cursor;In addition to being closed explicitly by the close statement, cursors are alsoclosed implicitly when the variable representing them goes out of scope. Forexample, if the cursor object is referenced by a variable declared locally to aframe and the frame closes without explicitly closing the cursor object, thecursor object is closed automatically.How You Can Manage Transactions with CursorsEach cursor must be opened and closed within a single transaction. Moreover,the state of the transaction affects the state of the cursor. For example, acursor is automatically closed in either of the following cases:• Its transaction is closed by either a commit or rollback.• Its transaction is aborted by an error.Some errors (for example, deadlock, logfull, and disk full) do not abort anentire transaction but do close any open cursors. If an error occurs while acursor is open, you should roll back the transaction and begin it again.If you are running with autocommit on (each database statement is a separatetransaction), a cursor is considered one transaction from the time it is openeduntil it is closed. Therefore, when autocommit is on and a cursor is open, youcan issue only cursor statements to access the database. If you issue anyother database access statements, the open cursor is closed automatically.For an explanation of using autocommit, see How Running with AutocommitOn Works (see page 187).You can use the inquire_sql statement with the transaction parameter todetermine the transaction state. For more information about the inquire_sqlstatement, see Handling Database Errors (see page 197) or the online help.How You Can Use Methods That Access the DatabaseThree system classes, BitmapObject, StringObject, and DataStream havemethods that access the database. The BitmapObject and StringObjectmethods are:InsertIntoDBPlaces the associated object in the databaseWorking with a Database 163

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

Saved successfully!

Ooh no, something went wrong!