| ilValidateInputData | input | logical | When true, evaluate the input data (= tables with prefix t_s). When false, evaluate the business data (= tables with prefix t_o). |
| olDoValidation | output | logical |
BLF
define variable oireturnstatus as integer no-undo.
if vcValidationExceptionList = ""
then olDoValidation = yes.
else do:
<M-1 run DataDescription
(input '' (icRowids),
input '' (icPkey),
input '' (icObjectIds),
input yes (ilAllTables),
output viFcReturnSuper (oiReturnStatus)) in database>
for each tFcDynRel on error undo, throw:
/* ================================================================= */
/* Look for create or delete. If found, always validate. */
/* ================================================================= */
if ilValidateInputData
then do:
tFcDynRel.thFcSBuffer:find-unique("where tc_Status = 'N' or tc_Status = 'D'") no-error.
olDoValidation = (tFcDynRel.thFcSBuffer:available or tFcDynRel.thFcSBuffer:ambiguous).
end.
else do:
tFcDynRel.thFcBuffer:find-unique("where tc_Status = 'N' or tc_Status = 'D'") no-error.
olDoValidation = (tFcDynRel.thFcBuffer:available or tFcDynRel.thFcBuffer:ambiguous).
end.
if olDoValidation
then return.
/* ================================================================= */
/* Evaluate updates field by field. */
/* ================================================================= */
viFieldNum = tFcDynRel.thFcSBuffer:num-fields.
create query vhQuery in widget-pool "non-persistent".
vhQuery:forward-only = yes.
if ilValidateInputData
then vhQuery:set-buffers (tFcDynRel.thFcSBuffer,tFcDynRel.thFcIBuffer).
else vhQuery:set-buffers (tFcDynRel.thFcBuffer,tFcDynRel.thFcIBuffer).
if ilValidateInputData
then vhQuery:query-prepare ("for each " + tFcDynRel.thFcSBuffer:name
+ " where " + tFcDynRel.thFcSBuffer:name + ".tc_Status = 'C'"
+ ", each " + tFcDynRel.thFcIBuffer:name
+ " where " + tFcDynRel.thFcIBuffer:name + ".tc_Rowid"
+ " = " + tFcDynRel.thFcSBuffer:name + ".tc_Rowid").
else vhQuery:query-prepare ("for each " + tFcDynRel.thFcBuffer:name
+ " where " + tFcDynRel.thFcBuffer:name + ".tc_Status = 'C'"
+ ", each " + tFcDynRel.thFcIBuffer:name
+ " where " + tFcDynRel.thFcIBuffer:name + ".tc_Rowid"
+ " = " + tFcDynRel.thFcBuffer:name + ".tc_Rowid").
vhQuery:query-open().
vhQuery:get-first().
do while not vhQuery:query-off-end:
do viFieldCount = 1 to viFieldNum:
if ilValidateInputData
then vhSOField = tFcDynRel.thFcSBuffer:buffer-field(viFieldCount).
else vhSOField = tFcDynRel.thFcBuffer:buffer-field(viFieldCount).
/* Some fields should always be ignored for evaluation */
if not (vhSOField:name = "tc_Rowid" or
vhSOField:name = "tc_ParentRowid" or
vhSOField:name = "tc_Status" or
vhSOField:name begins "LastModified" or
vhSOField:name begins "CustomShort" or
vhSOField:name begins "CustomCombo" or
vhSOField:name begins "CustomLong" or
vhSOField:name begins "CustomNote" or
vhSOField:name begins "CustomDate" or
vhSOField:name begins "CustomInteger" or
vhSOField:name begins "CustomDate")
then if not can-do (vcValidationExceptionList, "t" + tFcDynRel.tcFcTo + "." + vhSOField:name)
then if vhSOField:buffer-value <> tFcDynRel.thFcIBuffer:buffer-field(viFieldCount):buffer-value
then do:
olDoValidation = yes.
vhQuery:query-close().
delete object vhQuery.
return.
end.
end.
vhQuery:get-next().
end.
vhQuery:query-close().
delete object vhQuery.
end.
end.
finally:
if olDoValidation
and viTransactionID <> 0
then do:
/* open transaction and leave it open for re-use */
<I-40 {bFcOpenInstance
&CLASS = "Transaction"}>
end.
end finally.