I am working on MySQL 5.1.3 and using PHPMyAdmin 3.1.3.1 to access it. With PHP as the Server side scripting Language. My problem statement is can we call a Stored Procedure or Function from the Trigger statement so that when ever an INSERT|UPDATE|DELETE trigger is called, it calls the SP for updating some other tables according to the logic defined.
Share
Look here Mysql Trigger Syntax
It can be easier to define a stored procedure separately and then invoke it from the trigger using a simple
CALLstatement. This is also advantageous if you want to invoke the same routine from within several triggers.There are some limitations on what can appear in statements that a trigger executes when activated:
The trigger cannot use the
CALLstatement to invoke stored procedures that return data to the client or that use dynamic SQL. (Stored procedures are permitted to return data to the trigger throughOUTorINOUTparameters.)The trigger cannot use statements that explicitly or implicitly begin or end a transaction such as
STARTTRANSACTION,COMMIT, orROLLBACK.