Reputation: 177
Is it possible to return more than one rows and column in a single query inside a stored procedure or a trigger? and how can i fetch the data being return? do i need to use loop or some thing?
here is what i want:
DROP TRIGGER IF EXISTS `trgg`;
DELIMITER ;;
CREATE TRIGGER `trgg` AFTER INSERT ON tbl
FOR EACH ROW BEGIN
SET @result = (SELECT * FROM tbl2 WHERE field = 1 );
// i want to fetch the values return @result, is that possible?
// Or at least only the column only, not necessarily all the rows,
#### rest of the codes goes here #####
END ;;
i been researching this for about a day, but still i cant find the answer, is anybody here can help me on this
Upvotes: 0
Views: 3551
Reputation: 3261
You can use cursor inside trigger. the good example of cursor is http://dev.mysql.com/doc/refman/5.0/en/cursors.html
Declare cursor for your select statement. And in the loop fetch values of that cursor in some declared variable
Upvotes: 1