MySQL Forums
Forum List  »  French

Creer View dans un trigger
Posted by: Pariaud Thomas
Date: June 17, 2009 02:34AM

bonjour,
J essaye de creer une vue lors de l insertion dans une table
Voici le code du corps du trigger. J ai une erreur et je ne voit pas
Peu etre ce n est pas possible de creer une vue a la volee
Voici l erreur :
Explicit or implicit commit is not allowed in stored function or trigger.
Si quelqu'un a une idée :)

Code
------------------------------------------------------------------------
BEGIN
DECLARE nomview CURSOR FOR SELECT CONCAT('view_vente_magasin', new.`MAGASIN_ID`);
IF new.`MAGASIN_ID` > 3 THEN
CREATE VIEW nomview AS
SELECT `a`.`PRODUITS_MAGASIN_NOM` AS `Produit`,ifnull(sum(`b`.`QUANTITE`),0) AS `Quantite`
FROM (`merisefinal`.`produits_magasin` `a` LEFT JOIN (`merisefinal`.`factures` `c` LEFT JOIN `merisefinal`.`facture_produits_magasin` `b` ON(((`c`.`FACTURE_ID` = `b`.`FACTURE_ID`)
AND (`c`.`FACTURE_DATE` = curdate())
AND (`c`.`MAGASIN_ID` = new.`MAGASIN_ID`)))) ON((`a`.`PRODUITS_MAGASIN_ID` = `b`.`PRODUITS_MAGASIN_ID`))) GROUP BY `a`.`PRODUITS_MAGASIN_ID`;

END IF;
END;
------------------------------------------------------------------------------

Options: ReplyQuote


Subject
Views
Written By
Posted
Creer View dans un trigger
4616
June 17, 2009 02:34AM


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.