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.

How <strong>Programming</strong> for Multiple Sessions WorksHow You Can Use Cursors, DataStream Objects, and Multiple SessionsEvery cursor or DataStream object opened in QY_CURSOR mode has anassociated CursorObject object. One of the attributes of the CursorObjectsystem class is DBSession. This attribute contains a DBSessionObject, whichidentifies the database session in which the cursor or DataStream object wasopened.After you open a CursorObject object, OpenROAD uses the session associatedwith the DBSessionObject object in the CursorObject's DBSession attribute forany subsequent cursor statements.Therefore, when you issue a fetch, update, delete, or close cursor statement,or a FetchRow, DBInsert, DBUpdate, DBDelete or Close method on aDataStream object, the specified operation takes place in the session in whichthe cursor was opened, regardless of the session in which the frame isrunning.It is not necessary to switch explicitly to the session with which theCursorObject object is associated to perform a cursor operation. After thecursor statement completes, OpenROAD automatically returns to the session inwhich the frame was working before the cursor statement.How You Can Open a New Database SessionBefore you can open a session other than a frame's starting session, you mustcreate the DBSessionObject object for the new session by declaring a global orlocal reference variable of type DBSessionObject.Declaring the variable globally lets you open the session represented by thevariable in any frame of the application. If you declare a local variable, you canreference that variable in the frame in which the variable is declared or pass itto a frame or procedure called by that frame. You can open the session onlywithin the frame in which you declared it or in subsequent frames orprocedures called by that frame.The DBSessionObject system class provides the following two methods foropening a new connection to a database:• The Connect method• The OpenNew Connection methodConnect MethodUse this method to start a session that is different from any of the currentlyopen sessions, for example, a session with a different database or a differentset of DBMS flags.Working with a Database 191

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

Saved successfully!

Ooh no, something went wrong!