how to return nextval of oracle sequence into Delphi variable?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
punkicat
Posts: 3
Joined: Wed 26 Mar 2008 16:34

how to return nextval of oracle sequence into Delphi variable?

Post by punkicat » Wed 26 Mar 2008 18:47

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.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 27 Mar 2008 08:02

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;

punkicat
Posts: 3
Joined: Wed 26 Mar 2008 16:34

Post by punkicat » Thu 27 Mar 2008 08:34

Thank you,

it works fine.

Post Reply