project BLF > class Persistence (Progress) > method CreateFcSession

Description

Create a fcSession record directly in the DB.


Parameters


iiSessionInstanceIdinputinteger
icGlobalSessionIdinputcharacter
iiSessionLastCheckTimeinputinteger
itSessionLastCheckDateinputdate
iiGlobalSessionLastCheckTimeinputinteger
itGlobalSessionLastCheckDateinputdate
ilGlobalSessionNeedsUpdateinputlogical
iiSessionTimeOutinputinteger
iiGlobalSessionDebugLevelinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/progress.p)

if not (valid-handle(vhfcSessionQuery) and
        vifcSessionUID = vhfcSessionQuery:unique-id)
then do:
    create buffer vhfcSessionBuffer for table "fcSession":U in widget-pool "persistent".
    create query vhfcSessionQuery in widget-pool "persistent".
    vhfcSessionQuery:forward-only = yes.
    vhfcSessionQuery:set-buffers(vhfcSessionBuffer).
    vhfcSessionQuery:private-data = "Persistent".    /* do not ever delete this query */
    vifcSessionUID = vhfcSessionQuery:unique-id.
end.

do transaction on error undo, throw:

    vhfcSessionQuery:query-prepare
         ("for each fcSession where fcSession.SessionInstance_ID = ":U +
          string(iiSessionInstanceId)).
    vhfcSessionQuery:query-open().
    vhfcSessionQuery:get-first(exclusive-lock, no-wait).
    if vhfcSessionBuffer:available and vhfcSessionBuffer:locked
    then do:
        vhfcSessionQuery:query-close().
        assign oiReturnStatus = -3.
        return.
    end.
    if not vhfcSessionBuffer:available
    then vhfcSessionBuffer:buffer-create().
    
    assign vhfcSessionBuffer::SessionInstance_ID           = iiSessionInstanceId
           vhfcSessionBuffer::GlobalSessionId              = icGlobalSessionId
           vhfcSessionBuffer::SessionLastCheckTime         = iiSessionLastCheckTime
           vhfcSessionBuffer::SessionLastCheckDate         = itSessionLastCheckDate
           vhfcSessionBuffer::GlobalSessionLastCheckTime   = iiGlobalSessionLastCheckTime
           vhfcSessionBuffer::GlobalSessionLastCheckDate   = itGlobalSessionLastCheckDate
           vhfcSessionBuffer::GlobalSessionNeedsUpdate     = ilGlobalSessionNeedsUpdate
           vhfcSessionBuffer::GlobalSessionDebugLevel      = iiGlobalSessionDebugLevel
           vhfcSessionBuffer::SessionTimeOut               = iiSessionTimeOut.
    vhfcSessionBuffer:buffer-release().
end.

finally:
    if vhfcSessionQuery <> ? then vhfcSessionQuery:query-close().
end finally.