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
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
Without a direct connection, you are going to need an AppServer routine to get it for you, same as all data.