project BLF > class Persistence (Progress) > method DeleteNumber

Description

Remove the reference to a reserved number from the instance data.

PreCondition

This method is to be used by the BNumber class only.


Parameters


iiInstanceIdinputinteger
icClassNameinputcharacter
icNumberDatainputcharacter


Internal usage


unused


program code (program1/progress.p)

put-string(vat,1) = icNumberData.

if not (valid-handle(vhInstanceQuery) and
        viInstanceUID = vhInstanceQuery:unique-id)
then do:
    create buffer vhInstanceBuffer for table "fcInstance":U in widget-pool "persistent".
    create query vhInstanceQuery in widget-pool "persistent".
    vhInstanceQuery:forward-only = yes.
    vhInstanceQuery:set-buffers(vhInstanceBuffer).
    vhInstanceQuery:private-data = "Persistent".    /* do not ever delete this query */
    viInstanceUID = vhInstanceQuery:unique-id.
end.

vhInstanceQuery:query-prepare
 ("for each fcInstance where fcInstance.Instance_ID = ":U + string(iiInstanceId) +
  " and fcInstance.InstanceClassName = '" + icClassName +
  "' and fcInstance.InstanceSeq < 0").
vhInstanceQuery:query-open().
repeat transaction on error undo, throw:
    vhInstanceQuery:get-next(exclusive-lock, no-wait).
    if vhInstanceBuffer:locked
    then leave.
    if vhInstanceQuery:query-off-end
    then leave.
    if vhInstanceBuffer::InstanceData = vat
    then do:
        vhInstanceBuffer:buffer-delete().
        leave.
    end.
end.

finally:
    if vhInstanceQuery <> ? then vhInstanceQuery:query-close().
end finally.