project BLF > class Database Component > method DataSaveWorker

Description

A sub part of the transaction process.
This function must be public, so it can be called from the transaction component, but should not be used directly by the developer.


Parameters


oiReturnStatusoutputinteger


Internal usage


BLF
method database.DataSave
method Transaction.CommitTransaction


program code (program1/database.p)

<M-19 run DataDescription
   (input  '' (icRowids), 
    input  '' (icPkey), 
    input  '' (icObjectIds), 
    input  no (ilAllTables), 
    output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

/* nothing to save ? */
if not can-find (first tFcDynRel)
then do:
    if oiReturnStatus = -98
    then assign oiReturnStatus = 0.
    return.
end.

/* When the data received from the client is not validated, it can only be saved as a draft instance. */
/* When nothing was received from the client, maybe there is nothing to save */
if not vlFcDataValidated
then do:
    vlFcDataValidated = yes.
    for each tFcDynRel on error undo, throw:
        tFcDynRel.thFcBuffer:find-unique ("where tc_Status <> ''") no-error.
        if tFcDynRel.thFcBuffer:available
        or tFcDynRel.thFcBuffer:ambiguous
        then do:
            vlFcDataValidated = no.
            leave.
        end.
    end.
end.
    
if not vlFcDataValidated
then do:
    <M-17 run SetMessage
       (input  #T-18'Data to save ($1) has not been validated.':100(71)t-18# (icMessage), 
        input  vcFcComponentName (icArguments), 
        input  'vifcCurrentInstanceId' (icFieldName), 
        input  string (vifcCurrentInstanceId) (icFieldValue), 
        input  'S':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'BLF-308':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in database>
    assign oiReturnStatus = -3.
    return.
end.

<M-10 run PreSave (output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

<M-11 run StartPersistence
          (output vhFcComponent (ohPersistence), 
           output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

<M-20 run ClearBuffers  () in persistence>

<M-5 run WriteData
          (input  tFcDynRel (tDynRel), 
           input  {&TARGETPROCEDURE} (ihClass), 
           input  buffer tFcRowidConvert:handle (ihRowidConvert), 
           input  vcUserLogin (icUserLogin), 
           output viFcReturnSuper (oiReturnStatus)) in persistence>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

<M-3 run PostSave (output viFcReturnSuper (oiReturnStatus)) in database>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.