• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Oracle Sequence and JDBC

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just specify sequence.next() in your query string, where you want to insert a value from sequence.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much ,

seems it is working for oracle.

Thanks
Santosh
reply
    Bookmark Topic Watch Topic
  • New Topic