Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Inserting values to oracle

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,
I'm doing a program in JSP and Oracle.. In that the oracle table details are here
------------------------------------------------------
column
------------------------------------------------------
reg_no
name
password
confirm
-------------------------------------------------------

in this table the reg_no is a primary key and there is a sequence
ie., the number starts with 1000 and increment by 1

now from the jsp page.. i want to insert a new user registation details..

at that time the query i;m using is
insert into table_name (reg_no,name,password,confirm)values (reg_no.nextval,name,password,confirm);

but it is not inserting and showing errors..
so what should i do to insert the values in to the table where there is a sequence and a primary key!!

please help me.. ranchers..
thanks in advance

regards

Megha Rajeev
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Megha Rajeevan:

but it is not inserting and showing errors..





What error does it show ??

Shailesh
 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Shalish..
Thanks for replying and sorry for the lack of information..
Actully it is showing the error.. invalid column name.
ie., reg_no.nextval is a invalid column name..

what should i do to insert the auto number..

please help me ranchers..

thanks in advance

regards
Megha
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your syntax looks OK. Does the sequence reg_no exist and does your user have privileges to use it?

(BTW: when posting an exception message it is usually better to just cut and paste the message rather than posting what you think the message means. There is less scope for error that way)
[ May 23, 2006: Message edited by: Paul Sturrock ]
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Actully it is showing the error.. invalid column name.
ie., reg_no.nextval is a invalid column name..



I very much doubt that (your interpretation, not the error message). You probably have an error elswhere in your SQL statement.

Let me guess; you're using Statement, instead of PreparedStatement, and dynamically building a String variable to hold your SQL?

Post some code and we'll see what's wrong.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Megha,

To check if the sequence you are using exists and working or not try to run the following query on oracle through sqlplus (or any query runner interface)

select reg_no.nextval from dual;

If this results in a number then we can look further.

Thanks,
Sunil
 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u RancherS!!
Now the query is executing successfully..
I don't know what happened to it yesterday
when ever i try to insert the values it was inserting 2 times..
and when i restarted my system..
it is ok now

i think there is some problem with the system cache..

any way thank you very much
for your great support..

regards
Megha
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic