If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > create trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-08, 01:48
Pawan Kumar Pawan Kumar is offline
Registered User
 
Join Date: Mar 2008
Posts: 120
create trigger

There are two table A and B.

Fields of A :- Aid(PK), name, isactive, cdate, Bid

Fields of B:- Bid(PK),name,isactive ,cdate



There is no FK relation between A and B.



Trigger1:- If I insert new rocord in table A, new record with this data must be inserted in B table automatically. And Bid of table A must be updated by Bid of B in same record.

Example:

Insert into A values(1,’Pawan’,’Y’,’2008-10-16’);

After inserting this record data must be like below in tables….

Table A

1

Pawan

Y

2008-10-16

10



Table B

10

Pawan

Y

2008-10-16



Trigger2:- If I update any value in any record in table A, same must be updated in table B respectively.

Example:

Update A set name=’Kumar’ where Aid=1;

After this update data must be like below in tables..



Table A

1

Kumar

Y

2008-10-16

10



Table B

10

Kumar

Y

2008-10-16
__________________
Regards
Pawan Kumar
Reply With Quote
  #2 (permalink)  
Old 09-17-08, 08:29
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
you should think about combining your two tables instead of this complicated trigger scheme
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On