project BLF > class Persistence Layer > method CheckChanges

Description

Check if any child of a database record has been changed.


Parameters


icTableNameinputcharacterDatabase table name.
ihDestinationBufferinputhandleHandle to the class temp-table.
icParentRowidinputcharacterRowid of the database parent record.
olFoundoutputlogicalChanges found
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method persistence.CheckChanges
method other.ReadDataRecursive
method Progress.ReadDataRecursive


program code (program1/persistence.p)

/* ================================================================= */
/* Check if this table has children that where changed               */
/* ================================================================= */
if not can-find (first tDynRel where
                       tDynRel.tcFcFrom = icTableName)
then return.

/* ================================================================= */
/* Check if a record of this tables was changed                      */
/* ================================================================= */
create query vhTQuery in widget-pool "non-persistent".
vhTQuery:forward-only = yes.
vhTQuery:set-buffers(ihDestinationBuffer).
vhTQuery:query-prepare
    ("for each ":U + ihDestinationBuffer:name +
     " where ":U + ihDestinationBuffer:name + 
     ".tc_ParentRowid = '":U + icParentRowid +
     "' and ":U + ihDestinationBuffer:name +
     ".tc_status <> ''":U +
     " and ":U + ihDestinationBuffer:name +
     ".tc_status <> 'D'":U).
vhTQuery:query-open().
vhTQuery:get-first().

if not vhTQuery:query-off-end
then do:
    assign olFound = yes.
    vhTQuery:query-close().
    delete object vhTQuery.
    return.
end.

vhTQuery:query-prepare
    ("for each ":U + ihDestinationBuffer:name +
     " where ":U + ihDestinationBuffer:name + 
     ".tc_ParentRowid = '":U + icParentRowid + "'":U).
vhTQuery:query-open().
vhTQuery:get-first().

do while not vhTQuery:query-off-end:

    for each bDynRel where
             bDynRel.tcFcFrom = icTableName on error undo, throw:
        <M-1 run CheckChanges
           (input  bDynRel.tcFcTo (icTableName), 
            input  bDynRel.thFcBuffer (ihDestinationBuffer), 
            input  ihDestinationBuffer::tc_Rowid (icParentRowid), 
            output olFound (olFound), 
            output viFcReturnSuper (oiReturnStatus)) in persistence>
        if olFound
        then do:
            vhTQuery:query-close().
            delete object vhTQuery.
            return.
        end.
    end.
    
    vhTQuery:get-next().
end.

finally:
    if vhTQuery <> ?
    then do:
        vhTQuery:query-close().
        delete object vhTQuery.
    end.
end finally.