Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inserting values to oracle

 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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 ]
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • 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.
 
Sunil Dumpala
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic