MySQL Forums
Forum List  »  Quality Assurance

insert data into child table failing
Posted by: Joseph Diku
Date: April 13, 2012 09:19AM

Hi guys,
I have 2 tables profiles and address. profiles has the fields pid (Primary Key), surname, firstname. address has the fields addid (Primary Key), pid (foreign key), phone.

pid in table address references pid in table profiles and it its a foreign key in table address.

I insert data into profiles before i insert into address. I have an after insert on trigger as shown below;

create trigger ai_patient_profile_fer after insert on profile for each row
begin
\d //
insert into address set pid = new.pid;
end
//


When i try to insert data into address to fill in the phone column it fails.

Some one please advise me on the way forward. Should i use an UPDATE statement instead of INSERT. Please show me some sample code of how this is done, since i have been trying for so long without success. I am newbie to MySQL. Thanks.

Thank you all in advance.

Options: ReplyQuote


Subject
Views
Written By
Posted
insert data into child table failing
3887
April 13, 2012 09:19AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.