project BLF > class BCustomField > method BusinessFieldIsInUse
Description
check if an active custom business field is already used in database records
Parameters
icCustomFieldName | input | character | |
olIsInUse | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program1/bcustomfield.p)
if icCustomFieldName begins "t":U
then assign vcTable = substring(entry(1,icCustomFieldName,".":U),2,-1,"CHARACTER":U).
if num-entries(icCustomFieldName,".":U) = 2
then assign vcField = entry (2,icCustomFieldName,".":U).
/* not a database table */
if vcTable begins "CustomTable"
then return.
if vcTable = ""
or vcField = ""
then do:
<M-1 run SetMessage
(input 'Invalid field name.':U (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-62':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCustomField>
assign oiReturnStatus = -3.
return.
end.
assign vcQuery = "for each ":U + vcTable + "1 where ":U
+ vcTable + "1.":U + vcField + " <> ?":U.
if vcField begins "CustomShort":U
or vcField begins "CustomCombo":U
or vcField begins "CustomLong":U
or vcField begins "CustomNote":U
or vcField begins "QADC0":U
then assign vcQuery = vcQuery + " and ":U + vcTable + "1.":U + vcField + " <> ''":U.
if vcField begins "CustomInteger":U
or vcField begins "CustomDecimal":U
or vcField begins "QADD0":U
then assign vcQuery = vcQuery + " and ":U + vcTable + "1.":U + vcField + " <> 0":U.
<M-2 run StartPersistence (output vhFcComponent (ohPersistence),
output oiReturnStatus (oiReturnStatus)) in BCustomField>
if oiReturnStatus <> 0
then return.
<M-3 run CheckExistence
(input 'BCustomField.BusinessFieldIsInUse':U (icQueryName),
input vcQuery (icPrepare),
input vcTable + '1':U (icTables),
output olIsInUse (olEof),
output oiReturnStatus (oiReturnStatus)) in persistence>
if olIsInUse = ?
then olIsInUse = yes.
else olIsInUse = not olIsInUse.