Page 1 of 1

how to return nextval of oracle sequence into Delphi variable?

Posted: Wed 26 Mar 2008 18:47
by punkicat
Hello,

I've created a sequence and want return the value of nextval into my Delphi 2006 program:

Oracle sequence:

Code: Select all

CREATE SEQUENCE GDO.SEQ_SCHV2_INCR
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 9999999999
NOCACHE 
CYCLE 
NOORDER 
Sqlplus-command:

Code: Select all

SQLPLUS> select seq_schv2_incr.nextval from dual;

   NEXTVAL
----------
         21
How do I solve this with ODAC (v. 5.80.0.42)?
Can you give me a short code-example?

Thanks.

Posted: Thu 27 Mar 2008 08:02
by Plash
There is an example using TOraQuery component:

OraQuery.SQL.Text := 'select seq_schv2_incr.nextval from dual';
OraQuery.Open;
i := OraQuery.Fields[0].AsInteger;
OraQuery.Close;

Posted: Thu 27 Mar 2008 08:34
by punkicat
Thank you,

it works fine.