Description
Update children of records that where deleted in an optimistic lock situation.
Parameters
icTableName | input | character | |
ihDestinationBuffer | input | handle | Handle to the class temp-table |
icOldRowid | input | character | Parent rowid to replace. |
icNewRowid | input | character | Parent rowid to replace with (blanc if records must be deleted). |
ihClass | input | handle | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/persistence.p)
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 + icOldRowid + "'":U).
vhTQuery:query-open().
vhTQuery:get-first().
do while not vhTQuery:query-off-end:
assign ihDestinationBuffer::tc_ParentRowid = icNewRowid.
if ihDestinationBuffer::tc_Status <> "N":U
then do:
if icNewRowid = ""
or ihDestinationBuffer::tc_Status = "D":U
then do:
for each bDynRel where
bDynRel.tcFcFrom = icTableName on error undo, throw:
<M-1 run UpdateChanges
(input bDynRel.tcFcTo (icTableName),
input bDynRel.thFcBuffer (ihDestinationBuffer),
input ihDestinationBuffer::tc_Rowid (icOldRowid),
input '' (icNewRowid),
input ihClass (ihClass),
output viFcReturnSuper (oiReturnStatus)) in persistence>
if viFcReturnSuper <> 0
then do :
vhTQuery:query-close().
delete object vhTQuery.
assign oiReturnStatus = viFcReturnSuper.
return.
end.
end.
ihDestinationBuffer:buffer-delete().
end.
else do:
assign vhPdatabaseInst = ihClass
vcTRowid = <M-2 GetNumberForNew () in database>.
for each bDynRel where
bDynRel.tcFcFrom = icTableName on error undo, throw:
<M-3 run UpdateChanges
(input bDynRel.tcFcTo (icTableName),
input bDynRel.thFcBuffer (ihDestinationBuffer),
input ihDestinationBuffer::tc_Rowid (icOldRowid),
input vcTRowid (icNewRowid),
input ihClass (ihClass),
output viFcReturnSuper (oiReturnStatus)) in persistence>
if viFcReturnSuper <> 0
then do :
vhTQuery:query-close().
delete object vhTQuery.
assign oiReturnStatus = viFcReturnSuper.
return.
end.
end.
assign ihDestinationBuffer::tc_Rowid = vcTRowid
ihDestinationBuffer::tc_Status = "N":U.
end.
end.
vhTQuery:get-next().
end.
finally:
if vhTQuery <> ?
then do:
vhTQuery:query-close().
delete object vhTQuery.
end.
end finally.