Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle Sequence and JDBC

 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to insert the sequence values using jdbc. but i am not getting the next val in java code.


like in DB2 when i i have a idetity field then there is no need to have the insert statemet for this col.

but in oracle this is not working , how to get the next val in jdbc code


Thanks
Santosh
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just specify sequence.next() in your query string, where you want to insert a value from sequence.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adeel,
The correct syntax is "<sequence_name>.nextval" -- where <sequence_name> is the name of the sequence you require.

Perhaps you (and Santosh) should check the "SQL Reference" manual. It is available from here:

http://tahiti.oracle.com

Santosh,
Word of advice. All databases are not the same. If you now need to work exclusively with Oracle, then forget what you learned for DB2 -- and learn how to do it the Oracle way. Believe me, the Oracle way will be different from the DB2 way.

Good Luck,
Avi.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Avi Abrami:
Adeel,
The correct syntax is "<sequence_name>.nextval" -- where <sequence_name> is the name of the sequence you require.

Perhaps you (and Santosh) should check the "SQL Reference" manual. It is available from here:

http://tahiti.oracle.com


Avi, did you feel I wrote the real syntax. Actually not, my intend is to give an idea not the real syntax.

Its good if you are so kind to give the real syntax, "Spoonfeeding". Anyhow, its your style and that was mine .

Thanks for the reference.
[ March 30, 2005: Message edited by: Adeel Ansari ]
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much ,

seems it is working for oracle.

Thanks
Santosh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic