mutual clashes

Go down

mutual clashes

Post by mightyganesh on Mon Mar 22, 2010 4:09 pm

hey i came up with a different kind of doubt!

i had two tables with 3 fields each!
the first table's primary key (1st field) is assigned as the foreign key to the 2nd table(3rd field)
and the second table's primary key (1st field) is assigned as the foreign key to the first table(3rd field)

now if i want to insert values into both the tables then it says integrity problem!

how to over this prob???

to state with example

let the tables be
tab1(a , b, c)
and
tab2(x ,y ,z )

z is foreign key referring a in tab1
c is foreign key referring x in tab2

if i want to insert values
(10,'park avanue',20.00) to tab1 and
(20.00,'pen - free gift',10) to tab2

it says integrity prb!! how to over come it??? but after both the values are inserted they are satisfied!!!!
avatar
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 30

View user profile http://ganeshguna.blogspot.com

Back to top Go down

Re: mutual clashes

Post by Vineet_More on Mon Mar 22, 2010 4:23 pm

it might be not sure due to the reason tht when i am inserting the value in the tab1 due to its references to the foreign key it tries to check with the other table or tab2 n as it is nt able to find it displays the problem. but if values are inserted before hand then you modify the table with the above mentioned constraints it automatically checks with the constraints being specified and so error does nt come up..

Vineet_More

Posts : 27
Points : 31
Join date : 2010-02-26

View user profile

Back to top Go down

Re: mutual clashes

Post by Christopher on Mon Mar 22, 2010 4:24 pm

Try to temporarily disable the constraint using the following stmt.
Code:
ALTER TABLE <TABLE_NAME> NOCHECK CONSTRAINT <CONSTRAINT_NAME>;
Then try to insert the records one by one.
avatar
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 30

View user profile http://unixcpp.forumotion.com

Back to top Go down

Re: mutual clashes

Post by mightyganesh on Mon Mar 22, 2010 5:39 pm

hmm ya both ideas will work! i am not asking for modification of table rather i am asking is is possible to insert the data simultaneously or paralleled ???

or like a single insert command to insert values into both the tables????
avatar
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 30

View user profile http://ganeshguna.blogspot.com

Back to top Go down

Re: mutual clashes

Post by Vineet_More on Mon Mar 22, 2010 5:59 pm

I think simultaneous insertion of the data is not possible as only one query will be executed at a time...

Vineet_More

Posts : 27
Points : 31
Join date : 2010-02-26

View user profile

Back to top Go down

Re: mutual clashes

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum