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 WorksExamples of Opening New Database ConnectionsThe following examples show various ways to open a new databaseconnection.Using the OpenNewConnection method in the initialize blockThe following initialize block locally declares the reference variablesecond_session for the DBSessionObject and uses the OpenNewConnectionmethod to open a database session that is identical to the one for thecalling frame:initialize (second_session = DBSessionObject;) =beginsecond_session =CurFrame.DBSession.OpenNewConnection();...end;Using the Connect method in the initialize blockThe following initialize block uses the Connect method to open aconnection to the videos database, specifying the user as marg and settingthe arithmetic-handling mode of the session. The statement uses aglobally-declared reference variable third_session for the DBSessionObject:initialize (status = integer;) =beginstatus = third_session.Connect(database ='videos',flags = '-umarg -xw');end;Using the OpenNewConnection method in a frame-invoking statementThe following openframe statement in a calling frame establishes a new,identical database session for the called frame (newframe):newframe = openframe newframe with dbsession =CurFrame.DBSession.OpenNewConnection();How You Can Switch Database SessionsAfter you have opened additional database sessions for an application, you canswitch between open sessions by setting the DBSession attribute. Thisattribute is available for both the FrameExec object and the ProcExec object,letting you switch sessions in a frame or in a 4GL procedure.You can switch to an open session in any of the following locations:• The initialize block of the called frame• A frame-invoking statement (callframe, openframe, or gotoframe) in thecalling frame or procedureWorking with a Database 193

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

Saved successfully!

Ooh no, something went wrong!