project BLF > class Persistence (Progress) > method DeleteInstance

Description

Delete an instance from the fcInstance table


Parameters


iiInstanceIDinputinteger
ihClassinputhandle
icClassNameinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method BQueryCache.ApiDeleteQuery
method Progress.CleanupStateOnline


program code (program1/progress.p)

do transaction on error undo, throw:
    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)).
    vhInstanceQuery:query-open().
    vhInstanceQuery:get-first(exclusive-lock).
    do while not vhInstanceQuery:query-off-end:
        vhInstanceBuffer:buffer-delete().
        vhInstanceQuery:get-next(exclusive-lock).
    end.
    vhInstanceQuery:query-close().
end.

if vcStateDirectory <> ""
then os-delete value(vcStateDirectory + "/" + lc(icClassName) + string(iiInstanceID) + ".lob").