TOraScript and NEXTVAL

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
redhair
Posts: 11
Joined: Thu 20 Jun 2013 08:19

TOraScript and NEXTVAL

Post by redhair » Sat 03 Aug 2013 18:05

First you have to create a sequence :

Code: Select all

CREATE SEQUENCE s_test
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOMINVALUE
NOCYCLE
NOCACHE;
If you execute the following SQL statements with a TOraScript component, you get the
error message : ORA-02287:sequence number not allowed here.

Code: Select all

ALTER SEQUENCE s_test INCREMENT BY 100000;
SELECT s_test.NEXTVAL FROM dual;  -- Error ORA-02287
ALTER SEQUENCE s_test INCREMENT BY 1;
Details :
If the DataSet property of the TOraScript component is empty,
you get no error.
But in my TOraScript component the DataSet property
is filled with a TSmartQuery reference.


IDE: C++Builder XE4 Update 1 / ODAC 9.0.2 Professional
Direct mode and OCI mode

Thank you.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TOraScript and NEXTVAL

Post by AlexP » Tue 06 Aug 2013 08:33

Hello,

We couldn't reproduce the problem. Please check whether your query is correct. This error can occur, for example, when parentheses are inserted after a NEXTVAL expression, i.e.:

SELECT s_test.NEXTVAL FROM dual -- OK
SELECT s_test.NEXTVAL() FROM dual -- ORA-02287

redhair
Posts: 11
Joined: Thu 20 Jun 2013 08:19

Re: TOraScript and NEXTVAL

Post by redhair » Thu 22 Aug 2013 19:43

But in my TOraScript component the DataSet property
is filled with a TSmartQuery reference.
After your reply, I've tried to build a testproject
and I've got no SQL-runtime errors at all.
Then I changed the "QueryRecCount" property of the referenced
TSmartQuery to true, the error occurred again.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TOraScript and NEXTVAL

Post by AlexP » Fri 23 Aug 2013 08:36

Hello,

When enabling the QueryRecCount option, before executing a query, we execute an additional query to retrieve records, i.e.:

Code: Select all

SELECT COUNT(*) FROM (source query)
Oracle doesn't allow using sequences
in subqueries, therefore the error occurs

Post Reply