Sequence Error ORA-02287

50 views
Skip to first unread message

james....@students.plymouth.ac.uk

unread,
Mar 21, 2005, 8:01:47 AM3/21/05
to
Hi,

After an insert using nextval I try:


SELECT * FROM tblClients WHERE fldclient_id = (SELECT
client_id_seq.currval from Dual)


and get:


java.sql.SQLException: ORA-02287: sequence number not allowed here


I've read lots on sequence's etc and I can't see why I cant get the
currval.
(I'm in Jdeveloper btw)

Thanks,

Jim.

Deepa balu via DBMonster.com

unread,
Mar 21, 2005, 8:27:24 AM3/21/05
to

Do not use a sequence in a where-clause, a query with an order by, group
by, distinct, a set operation, an aggregate function, in a delete, in a
view, or anywhere other than an insert, update, or select.

Please look in Oracle8i SQL Reference for the rules on when to use sequence
values CURVAL and NEXTVAL.

--
Message posted via http://www.dbmonster.com

jfk303

unread,
Mar 21, 2005, 9:40:18 AM3/21/05
to

Thanks for the reply,

Sorry if this is more of a Java question rather than o.d:

Ok, I'm now putting the currrval into a variable. My query returns a
RecordSet, could anyone tell me how to get the value from the RecordSet
into a variable.

Whats wrong with this:

RecordSet myResults = DatabaseConnection.ExecuteQuery("SELECT
my_seq.currval FROM DUAL");

int currentValue = myResults.getInt("my_seq.currval");

Thanks for any answers,

Jim

Reply all
Reply to author
Forward
0 new messages