dbTalk Databases Forums  

Sequence Error ORA-02287

comp.databases.oracle comp.databases.oracle


Discuss Sequence Error ORA-02287 in the comp.databases.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
james.kennedy@students.plymouth.ac.uk
 
Posts: n/a

Default Sequence Error ORA-02287 - 03-21-2005 , 07:01 AM






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.


Reply With Quote
  #2  
Old   
Deepa balu via DBMonster.com
 
Posts: n/a

Default Re: Sequence Error ORA-02287 - 03-21-2005 , 07:27 AM







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

Reply With Quote
  #3  
Old   
jfk303
 
Posts: n/a

Default Re: Sequence Error ORA-02287 - 03-21-2005 , 08:40 AM




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 With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.