project QadFinancials > class BSharedSetMerge > method MergeValidateCompareKeys

function returns integer

Description

This method compares two records based on their values of key columns.


Parameters


icTableNameinputcharacter
ihQuery1inputhandle
ihQuery2inputhandle
ocKeyValueoutputcharacter


Internal usage


QadFinancials
method BSharedSetMerge.MergeValidateCompare


program code (program6/bsharedsetmerge.p)

/* =================================================================================================== */
/* Method      : MergeValidateCompareKeys                                                              */
/* Desc        : This function compares two records based on their values of key columns.              */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  Query1               Handle to query 1 (master)                                       */
/*          (I)  Query2               Handle to query 2 (redundant)                                    */
/*          (O)  KeyValue             Value of key(s)                                                  */
/* Return:       CompareResult        Result of compare of two records                                 */
/*                                    -1     Record in table 1 < Record in table 2                     */
/*                                    0      Record in table 1 = Record in table 2                     */
/*                                    1      Record in table 1 > Record in table 2                     */
/* Note:         Program has to be in the same segment as MergeValidate (sharing of MergeValidateField */
/* =================================================================================================== */

/* =================================================================================================== */
/* Calculate value of key columns                                                                      */
/* =================================================================================================== */
if not ihQuery1:query-off-end 
then assign vcKeyValue1 = <M-6 MergeValidateGetKeyValue  (input  ihQuery1 (ihQuery)) in BSharedSetMerge>. 

if not ihQuery2:query-off-end
then assign vcKeyValue2 = <M-4 MergeValidateGetKeyValue  (input  ihQuery2 (ihQuery)) in BSharedSetMerge>.
 
/* =================================================================================================== */
/* Are there still records to compare                                                                  */
/* =================================================================================================== */
if ihQuery1:query-off-end   /* missing record in query1 (master) */
then do:
    assign ocKeyValue = vcKeyValue2.
    return 1.
end.

if ihQuery2:query-off-end   /* missing record in query2 (redundant) */
then do:
    assign ocKeyValue = vcKeyValue1.
    return -1.
end.

/* =================================================================================================== */
/* Compare records of key fields                                                                       */
/* =================================================================================================== */
if vcKeyValue1 = vcKeyValue2
then do:
    assign ocKeyValue = vcKeyValue1.
    return 0.
end.
else if vcKeyValue1 < vcKeyValue2
then do:
    assign ocKeyValue = vcKeyValue1.
    return -1.
end.
else do:
    assign ocKeyValue = vcKeyValue2.
    return 1. 
end.


return -98.