project BLF > class Persistence (Progress) > method GetCurrentValue

function returns integer

Description

Lookup the current-value of a database sequence


Parameters


icSequenceinputcharacterdatabase sequence name

It is possible to provide extra sequences not known in the application database by extending the persistence layer class and adding a method named 'Current<icSequence>' which will be responsible for returning a unique value.


Internal usage


BLF
method Progress.ConnectionValid


program code (program1/progress.p)

find first tSequenceList where
           tSequenceList.tcSequenceName = icSequence no-error.
if not available tSequenceList
then do:
    create tSequenceList.
    assign tSequenceList.tcSequenceName = icSequence.

    /* internal procedure overrides database access */
    if can-do ({&TARGETPROCEDURE}:internal-entries,"Current":U + icsequence)
    then assign tSequenceList.tcDatabaseName = "_run":U.
    else 
        assign tSequenceList.tcDatabaseName = <M-3 GetSeqDB  (input  icSequence (icSequence)) in Progress>.
end.

if tSequenceList.tcDatabaseName = "_run":U
then do:
    run value ("Current":U + icsequence) in {&TARGETPROCEDURE}
       (output viDBV).
    return viDBV.
end.
else if tSequenceList.tcDatabaseName = ""
then return ?.
else do:
   if dbtype(tSequenceList.tcDatabaseName) = "Oracle" then
      return 0.
   else 
      return dynamic-current-value(icSequence,tSequenceList.tcDatabaseName).
end.