Navigation: Language Reference > 13 - Built-in Functions >====== LOGOUT (begin transaction) ====== | |
LOGOUT(timeout [, file, … , file ] )
LOGOUT | Initiates transaction processing. |
timeout | A numeric constant or variable specifying the number of seconds to attempt to begin the transaction for a file before aborting the transaction and posting an error. |
file | The label of a FILE declaration. There may be multiple file parameters, separated by commas, in the parameter list (up to 100). If no file is specified, all files in the transaction must have been previously named using PROP:Logout. |
The LOGOUT statement initiates transaction processing for a specified set of files. All files in the transaction set must have the same file driver and must already be open.
LOGOUT informs the file driver that a transaction is beginning. The file driver then performs the actions necessary to that file system to initiate transaction processing for the specified set of files. For example, if the file system requires that the files be locked for transaction processing, LOGOUT automatically locks the files.
Only one LOGOUT transaction may be active at a time. A second LOGOUT statement without a prior COMMIT or ROLLBACK generates errorcode 56.
The behavior of LOGOUT is file driver dependent, especially with SQL based drivers. Please see the Supported Commands and Attributes section for more information on each driver. In general, a LOGOUT on SQL based files affects all files on a connection that is associated with a file in the logout list, If you do not want a particular table logged out, you must open it on a different connection by using a different OWNER string.
Errors Posted:
32 | File Is Already Locked |
37 | File Not Open |
48 | Unable to Log Transaction |
56 | LOGOUT Already Active |
80 | Function Not Supported |
Example:
LOGOUT(1,OrderHeader,OrderDetail) !Begin Transaction
DO ErrHandler !always check for errors
ADD(OrderHeader) !Add Parent record
DO ErrHandler !always check for errors
LOOP X# = 1 TO RECORDS(DetailQue) !Process stored detail records
GET(DetailQue,X#) !Get one from the QUEUE
DO ErrHandler !always check for errors
Det:Record = DetailQue !Assign to record buffer
ADD(OrderDetail) !and add it to the file
DO ErrHandler !always check for errors
END
COMMIT !Terminate successful transaction
ASSERT(~ERRORCODE())
ErrHandler ROUTINE !Error routine
IF NOT ERRORCODE() THEN EXIT. !Exit here if no error
Err“ = ERROR() !else save the error message
ROLLBACK !Rollback the transaction
ASSERT(~ERRORCODE())
BEEP !Alert the user
MESSAGE('Transaction Error - ' & Err”)
EXIT !and exit
See Also: