How You Can Switch Sessions in a Called Frame
In addition to opening a new database session for a called frame in the initialize block of the called frame or the frame-invoking statement of the calling frame or procedure, you also can switch sessions for a called frame in either of these locations.
By default, a called frame inherits the value of the DBSession attribute from its calling frame or procedure. To switch sessions as you invoke the frame, you must change the value of this attribute in the frame-invoking statement. To switch sessions in the called frame, you use its initialize block.
The following examples demonstrate each of these methods:
• Frame-invoking statement
You can use the with clause with the openframe, gotoframe, or callframe statement to place the application in a different open session. For example, the following statement opens the newframe frame and places the application in the session represented by the DBSessionObject third_session:
field1 = callframe newframe with dbsession = third_session;
• Initialize block
You can use a statement in the called frame's initialize block to place the application in a different open session. If the reference variable that represents the DBSessionObject for the target session is a global variable, you can simply assign that variable value to the DBSession attribute of the called frame, for example:
initialize() =
begin
CurFrame.DBSession = second_session;
...
end;
If the reference variable was declared as a local variable in the calling frame, you must pass the variable to the called frame as a parameter and then assign the value to the DBSession attribute, for example:
/* in the calling frame */
field1 = callframe newframe
(sessno = second_session);
/* in the called frame */
initialize (
sessno = DBSessionObject;) =
begin
CurFrame.DBSession = sessno;
...
end;
If you use FrameExec's ParentFrame attribute to assign a called frame to a parent other than the calling frame, the called frame has the same session as the calling frame, not of the assigned parent. The following illustration of DBSessions and ParentFrames shows this process: