4GL sequence access from SQL

Posted by Andrzej.Sz on 28-Mar-2018 13:51

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

Posted by Ken McIntosh on 28-Mar-2018 15:01

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.

All Replies

Posted by Ken McIntosh on 28-Mar-2018 13:58

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

Posted by Andrzej.Sz on 28-Mar-2018 14:08

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

OE 11.6.4

Andrzej

Posted by Andrzej.Sz on 28-Mar-2018 14:16

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

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

Posted by Ken McIntosh on 28-Mar-2018 14:34

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)

Posted by Andrzej.Sz on 28-Mar-2018 14:50

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

Andrzej

Posted by Ken McIntosh on 28-Mar-2018 15:01

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.

Posted by Andrzej.Sz on 28-Mar-2018 15:27

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

Andrzej

This thread is closed