4GL sequence access from SQL - Forum - OpenEdge Deployment - Progress Community
 Forum

4GL sequence access from SQL

This question is answered

Is it possible to access (CURRVAL/NEXTVAL) 4GL sequence from SQL ? How to do it ?

I've tried to use KB article https://knowledgebase.progress.com/articles/Article/P183766 but I've got SQL syntax error.

Regards

Andrzej

Verified Answer
  • Yes, if you're running it from a Progress program.

    You could use sql explorer command line utility:

    proenv>sqlexp -db <dbname> -H <host|ip> -S <port|service> -user <userid> -pass <password>

    SQLExplorer>SELECT PUB.NextCustNum.CURRVAL from PUB."_File" WHERE "_File-Name" = 'Customer'.

    Why do you want to do it from SQL?  You can get the same value from ABL using the example I provided.

    Kenneth S. McIntosh

    Principal Technical Support Engineer

     

     

All Replies
  • What is your sql statement and the exact text of the error?  Also what version are you using?

    Kenneth S. McIntosh

    Principal Technical Support Engineer

     

     

  • SELECT PUB.NextCustNum.CURRVAL from PUB."_File" WHERE "_File-Name" = 'Customer'.

    OE 11.6.4

    Andrzej

  • ** Niezrozumiały tekst po -- "CURRVAL from PUB". (247)

    **  Linia 1 -- Niewłaściwe wyrażenie SQL. (945)

  • I see you're running this from the ABL, not SQL-92.  When using the ABL to execute SQL it uses SQL-89 (and btw this is deprecated functionality).  I believe the NEXTVAL stuff only applies in SQL 92.  You can use the NEXT-VALUE() function to get the next value from the sequence, as follows:

    NEXT-VALUE(NextCustNum)

    Kenneth S. McIntosh

    Principal Technical Support Engineer

     

     

  • Is Developer Studio using SQL-89 too? How to use SQL-92 and display CURRVAL?

    Andrzej

  • Yes, if you're running it from a Progress program.

    You could use sql explorer command line utility:

    proenv>sqlexp -db <dbname> -H <host|ip> -S <port|service> -user <userid> -pass <password>

    SQLExplorer>SELECT PUB.NextCustNum.CURRVAL from PUB."_File" WHERE "_File-Name" = 'Customer'.

    Why do you want to do it from SQL?  You can get the same value from ABL using the example I provided.

    Kenneth S. McIntosh

    Principal Technical Support Engineer

     

     

  • I was using ODBC access only for reporting. And now I'm trying to use it for updating too. Is it possible ?

    Andrzej