MySQL Forums
Forum List  »  Triggers

Select with update (Select trigger)
Posted by: Ronald Albury
Date: June 28, 2011 11:59AM

I'm sure this is simple, and it is just my lack of understanding of stored procedures that is standing in my way.

Lets say I have a table with several data columns. There is also a boolean column, FLAG, that is initialized with the value FALSE. I want FLAG to be updated to TRUE if that row of the database has been selected.

I can do it with two different sql statements:
Select * from TableX where <very long and complex criteria>;
Update TableX set FLAG=TRUE where <very long and complex criteria>;
or
Select * from TableX where <very long and complex criteria>:
<process results, remembering the primary key for each record>
Update TableX set FLAG=TRUE where <primary key> in (<remembered primary keys>);

What I want to know is if I can embed the Select in a stored procedure (lets call it, UpdateQuery), and have that stored procedure do the update on each row automatically:
Select * from UpdateQuery where <very long and complex criteria>;

This is sort of like a Select Trigger

Options: ReplyQuote


Subject
Views
Written By
Posted
Select with update (Select trigger)
5055
June 28, 2011 11:59AM


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.