Salesforce

4GL/ABL: How to Programmatically dump and load SCV's from the _sequence table?

« Go Back

Information

 
Title4GL/ABL: How to Programmatically dump and load SCV's from the _sequence table?
URL NameP122615
Article Number000116909
EnvironmentProduct: OpenEdge
Version: All supported versions
OS: All supported platforms
Question/Problem Description
4GL/ABL: How to Programmatically dump and load the _sequence table
How to generate ABL code to dump and load the Sequence Current Values
How to generate ABL code to dump _seqvals.d then load current sequence values
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution

The Data Administration tool provides an interface for dumping and loading the current values of your sequences.  This article specifically addresses how to do this programmatically and using dynamic constructs so that it can be done in pre-compiled r-code.

It is not possible to dump and load SEQUENCES using the Progress Data Administration tool with a Runtime license, so because of this you may want to create your own program that will do this outside the Data Administration tool.


The following Article uses dynamic statements to dump and load sequence current values, that are available since OpenEdge 10.1C:

This Article uses statements that will also run prior to OpenEdge 10.1C

To dump Sequence Current Values:

The following ABL code generates a 4GL procedure to dump the sequence values:

/* GenerateCodeToDumpSequenceValues.p */
OUTPUT TO DumpSequenceValues.p.
    PUT UNFORMATTED "OUTPUT TO _SeqVals.d." SKIP.
    FOR EACH _Sequence no-lock:
        PUT UNFORMATTED
            "    EXPORT " _Sequence._Seq-Num " " QUOTER(_Sequence._Seq-Name) " CURRENT-VALUE( " _seq-name ")." SKIP.
    END.
    PUT UNFORMATTED "OUTPUT CLOSE.".
OUTPUT CLOSE.

Example: The above procedure generates the following code to dump the sequence values from the sports2000 database:

/* DumpSequenceValues.p */
OUTPUT TO _SeqVals.d.
    EXPORT 9 "NextBinNum" CURRENT-VALUE( NextBinNum).
    EXPORT 0 "NextCustNum" CURRENT-VALUE( NextCustNum).
    EXPORT 11 "NextEmpNum" CURRENT-VALUE( NextEmpNum).
    EXPORT 1 "NextInvNum" CURRENT-VALUE( NextInvNum).
    EXPORT 12 "NextInvTransNum" CURRENT-VALUE( NextInvTransNum).
    EXPORT 3 "NextItemNum" CURRENT-VALUE( NextItemNum).
    EXPORT 7 "NextLocalDefNum" CURRENT-VALUE( NextLocalDefNum).
    EXPORT 2 "NextOrdNum" CURRENT-VALUE( NextOrdNum).
    EXPORT 10 "NextPONum" CURRENT-VALUE( NextPONum).
    EXPORT 4 "NextRefNum" CURRENT-VALUE( NextRefNum).
    EXPORT 6 "NextSupplNum" CURRENT-VALUE( NextSupplNum).
    EXPORT 5 "NextVisitor" CURRENT-VALUE( NextVisitor).
    EXPORT 8 "NextWareNum" CURRENT-VALUE( NextWareNum).
OUTPUT CLOSE.

To load Sequence Current Values:

The following ABL code generates a 4GL procedure to dump the sequence values:
 

/* GenerateCodeToLoadSequenceValues.p */
OUTPUT TO "LoadSeqValues.p".
PUT UNFORMATTED
    "DEFINE VARIABLE SequenceNumber       AS CHARACTER NO-UNDO." SKIP
    "DEFINE VARIABLE SequenceName         AS CHARACTER  NO-UNDO." SKIP
    "DEFINE VARIABLE SequenceCurrentValue AS INTEGER    NO-UNDO." SKIP
    "INPUT FROM _SeqVals.d." SKIP
    "REPEAT:" SKIP
    "   IMPORT SequenceNumber SequenceName SequenceCurrentValue." SKIP
    "   CASE SequenceName:" SKIP.

FOR EACH _Sequence NO-LOCK:
    PUT UNFORMATTED
        "      WHEN " QUOTER(_Seq-Name) " THEN CURRENT-VALUE(" _Seq-Name ") = SequenceCurrentValue." SKIP.
END.
PUT UNFORMATTED
    "   END CASE."SKIP
    "END." SKIP
    "INPUT CLOSE." SKIP.
OUTPUT CLOSE.

Example: The above procedure generates the following code to load the sequence values from the sports2000 database:

/* LoadSeqValues.p */
DEFINE VARIABLE SequenceNumber AS CHARACTER NO-UNDO.
DEFINE VARIABLE SequenceName AS CHARACTER  NO-UNDO.
DEFINE VARIABLE SequenceCurrentValue AS INTEGER    NO-UNDO.
INPUT FROM _SeqVals.d.
REPEAT:
   IMPORT SequenceNumber SequenceName SequenceCurrentValue.
   CASE SequenceName:
      WHEN "NextBinNum" THEN CURRENT-VALUE(NextBinNum) = SequenceCurrentValue.
      WHEN "NextCustNum" THEN CURRE.NT-VALUE(NextCustNum) = SequenceCurrentValue.
      WHEN "NextEmpNum" THEN CURRENT-VALUE(NextEmpNum) = SequenceCurrentValue.
      WHEN "NextInvNum" THEN CURRENT-VALUE(NextInvNum) = SequenceCurrentValue.
      WHEN "NextInvTransNum" THEN CURRENT-VALUE(NextInvTransNum) = SequenceCurrentValue.
      WHEN "NextItemNum" THEN CURRENT-VALUE(NextItemNum) = SequenceCurrentValue.
      WHEN "NextLocalDefNum" THEN CURRENT-VALUE(NextLocalDefNum) = SequenceCurrentValue.
      WHEN "NextOrdNum" THEN CURRENT-VALUE(NextOrdNum) = SequenceCurrentValue.
      WHEN "NextPONum" THEN CURRENT-VALUE(NextPONum) = SequenceCurrentValue.
      WHEN "NextRefNum" THEN CURRENT-VALUE(NextRefNum) = SequenceCurrentValue.
      WHEN "NextSupplNum" THEN CURRENT-VALUE(NextSupplNum) = SequenceCurrentValue.
      WHEN "NextVisitor" THEN CURRENT-VALUE(NextVisitor) = SequenceCurrentValue.
      WHEN "NextWareNum" THEN CURRENT-VALUE(NextWareNum) = SequenceCurrentValue.
   END CASE.
END.
INPUT CLOSE.

Workaround
Notes
Keyword Phrase
Last Modified Date1/11/2024 6:04 PM

Powered by