Getting next-value from a data source

Posted by PeterWokke on 05-Jan-2015 08:52

What is the best practice to obtain next-value from a database sequence if you haven't a direct connection to your database. 

with attach-data-source to a data-source I can attach a database table.

How to get a link to the database yo obtain a next-value from a database sequence?

Thanks for some guidelines and advise.  

Kind regards,  Peter Wokke

All Replies

Posted by Peter Judge on 05-Jan-2015 09:12

Before you attach-data-source() you will need a db connection present (either made via -db on the command line or the connect statement).

Once you have that connection, you can just use next-value(<dbname>).

You can check for the existence of a specific db connection in a couple of ways, but the easiest is to use the connected() function. Something like the very simple example below.

def var cDBName as character.
def var iVal as int64.

cDBName = 'sports2000'.

connect value('-db ' + cdbname).

if connected(cdbname) then
  iVal = next-value(cDbname).
else
  undo, throw new AppError('DB not connected: ' + cdbname, 0).


hth,

-- peter

Posted by Thomas Mercer-Hursh on 05-Jan-2015 10:32

Without a direct connection, you are going to need an AppServer routine to get it for you, same as all data.

This thread is closed