project BLF > class Persistence (Progress) > method UpdateBufferInfo

Description

Keep handles to class temp-tables and their fields, to speed up reading and writing.


Parameters


icTableNameinputcharacterDatabase table name
ihDestinationBufferinputhandleHandle to the buffer of the temp-table that contains the components data.
ihIDestinationBufferinputhandleHandle to the buffer of the temp-table that contains the components optimistic lock data.
ihClassinputhandle
ohBufferoutputhandleBuffer on the database table.
ohQueryoutputhandle
oiReturnStatusoutputinteger


Internal usage


BLF
method Progress.ReadDataRecursive
method Progress.WriteData


program code (program1/progress.p)

if ihClass <> ?
then if ihClass:file-name begins "program/"
     then vcClassName = "persistent-" + substring (entry(1,ihClass:file-name,"."),9,-1,"CHARACTER").
     else if ihClass:file-name begins "ins/ins__"
     then vcClassName = "persistent-" + substring (entry(1,ihClass:file-name,"."),10,-1,"CHARACTER").

find first tBuffers where
           tBuffers.thTempBuffer = ihDestinationBuffer and
           tBuffers.tiTempUID    = ihDestinationBuffer:unique-id no-error.
if not available tBuffers
then do:
    create tBuffers.
    assign tBuffers.tcTable       = icTableName
           tBuffers.thTempBuffer  = ihDestinationBuffer
           tBuffers.tiTempUID     = ihDestinationBuffer:unique-id.
    create buffer tBuffers.thBuffer for table icTableName in widget-pool "persistent".
    create query tBuffers.thQuery in widget-pool "persistent".
    tBuffers.thQuery:forward-only = yes.
    tBuffers.thQuery:set-buffers(tBuffers.thBuffer).
    tBuffers.thQuery:private-data = "Persistent".

    do viFcCount1 = 1 to ihDestinationBuffer:num-fields:
    
        assign vhTTField = ihDestinationBuffer:buffer-field(viFcCount1).
        if vhTTField:help = "Calc#":U
        then next.
        
        assign vhDbField = ?.
        assign vhDbField = tBuffers.thBuffer:buffer-field(vhTTField:name) no-error.
        if vhDbField = ?
        then do:
            <M-2 run ErrorMessage
               (input  #T-2'The application database is not up-to-date. (Missing field $1).':255(5127)T-2# (icMessage), 
                input  icTableName + '.':U + vhTTField:name (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  '' (icRowid), 
                input  ihClass (ihClass)) in Progress>
            assign oiReturnStatus  = -5.
            return.
        end.
       
        create tBufferFields.
        assign tBufferFields.thBufferField       = vhDbField
               tBufferFields.thDestinationField  = vhTTField
               tBufferFields.thIDestinationField = ihIDestinationBuffer:buffer-field(vhDbField:name)
               tBufferFields.thTempBuffer        = ihDestinationBuffer
               tBufferFields.tcFieldName         = vhDbField:name.
    end.
end.

assign ohBuffer       = tBuffers.thBuffer
       ohQuery        = tBuffers.thQuery.