MySQL Forums
Forum List  »  Stored Procedures

Re: Trigger calling stored procedure
Posted by: William Chiquito
Date: December 30, 2008 06:29PM

Hi Jim,

Try:
DELIMITER $$

DROP TRIGGER `updt_tbl1`$$

CREATE TRIGGER `updt_tbl1` BEFORE UPDATE ON `main_table`
FOR EACH ROW
   CALL a_stored_procedure(NEW.col1, NEW.col2, OLD.tblkey);
$$

DELIMITER ;

DELIMITER $$

DROP PROCEDURE IF EXISTS `a_stored_procedure`$$

CREATE PROCEDURE `a_stored_procedure`(val1 INT, val2 INT, val3 INT)
BEGIN
UPDATE table2 SET col1 = val1, col2 = val2 WHERE tblkey = val3;
UPDATE table3 SET col1 = val1, col2 = val2 WHERE tblkey = val3;
END$$

DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
19623
December 30, 2008 04:21PM
6697
December 30, 2008 06:07PM
6005
December 31, 2008 09:33AM
Re: Trigger calling stored procedure
6029
December 30, 2008 06:29PM


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.