MySQL Forums
Forum List  »  Triggers

looking for a row handle like C++'s this-> pointer
Posted by: pdgilbert
Date: March 21, 2006 03:01PM

I'm attempting to create a trigger that will sum two columns in a row and store it in another column of that row, then add that sum to a total in another table. I have created two stored procedures:
1. Takes key as an argument, sums the two columns of table1 referenced by key, stores the result in another column of table1 with same key (table1 also references a key in table2)
2. Takes table2.key as an argument, sums the totals from rows in table1 that contain that key reference, and stores it in table2

Both of these procedures take an index key as input. This is fine as long as I am manually calling the procedures, but I would like to make a trigger for it instead. The trigger (tripped when table1.column2 is updated) would call procedure1 and pass the current row's key to it, then call procedure2 and pass the reference value to the second table. I just don't know how to give it to the trigger, since the index and reference will change according to the row that kicks the trigger.

I need something that tells the trigger which row it is currently working on so I can retrieve the data from that row. I'm sure this can be done programmatically outside of the mysql server, but I would prefer to leave this process on the server. Since I'm learning as I go along, this may just turn out to be something I missed in the manual.

Options: ReplyQuote


Subject
Views
Written By
Posted
looking for a row handle like C++'s this-> pointer
2850
March 21, 2006 03:01PM


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.