This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem while inserting values

 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my databe table structure is as follows


name ssn address salary superssn

ok

here foreign key is superssn and reference is also in the same table.

so while inserting values am getting ORA-02291: error how do i resolve this??
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
superssn is referring ssn

so not able to insert any values at all
 
Campbell Ritchie
Sheriff
Pie
Posts: 49776
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this thread would sit more happily in another forum . . .

Please provide more details about your insert statement or whatever.
What is "ssn"? What type of variable is it, and also superssn? Which is the primary key in your table.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ssn is a varchar

superssn is also varchar

primary key is ssn


sorry for posting it here. i didnt find any sql forum here in javaranch.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
superssn is the foreign key so am not able to insert any values

when i try to insert values it will not the superssn value

for example

say ssn is 1 and superssn is 2 in the first insert .then since 2 is not available at that point . it shows error.

but how do i solve this. some values has to be entered right?
 
Henry Wong
author
Marshal
Pie
Posts: 21405
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for posting it here. i didnt find any sql forum here in javaranch


Posting to the right forum is a two-way street. You stand a much better chance of having people who can answer your question if you do. You are kinda wasting your time by posting to any random forum.

Regardless, the closest forum for this, is probably the JDBC forum, which hopefully, this topic will be moved to.

Henry
 
Campbell Ritchie
Sheriff
Pie
Posts: 49776
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please provide full details of the table, and the insert statement.
 
Heather Rose
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly does your error say? And please provide details on exactly what you are trying to do.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

this is my create query


[ September 08, 2008: Message edited by: yuvraj kotegar ]
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
table gets created ok

then when i try to insert values i get the following error

ORA-02291: integrity constraint (SYSTEM.SYS_C003019) violated - parent key not
found

how to insert atleast one record??
 
Campbell Ritchie
Sheriff
Pie
Posts: 49776
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have got the concept that you are inserting a row with a reference to a previous row; the very 1st row cannot refer to other rows, so it either must refer to itself, or to nothing.

For the 1st row use "null" for superssn or use its own value.

If you have designed your table that it not only contains the employee's name but also their supervisor's id, then you are designing a "tree" inside the table ( ) and you ought to have a separate supervisor table.
[ September 09, 2008: Message edited by: Campbell Ritchie ]
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the solution guys

 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks people for all your time and help

:thumb:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic