Le forum (ô combien francophone) des utilisateurs de Powerbuilder.




Bonjour,
J'ai un trigger sur l'insertion de ligne.
Je voudrais que si le trigger plante, la ligne soit quand même inséré.
Comment puis-je faire ?
Hors ligne














Bonjour, c'est un trigger after insert ?
PS : ne pas oublier les précisions de rigueur
Hors ligne




le after n'existe pas en sybase.
c'est juste for insert
Hors ligne














d'où l'utilité de préciser la base
essaye d'intercepter l'erreur du trigger (clause CATCH, EXCEPTION ou autre)
Hors ligne










salut
gere le code du trigger dans une procedure
et gere l'erreur dans cette procedure
Hors ligne






Bonjour,
Je ne connais pas le contenu et la structure de ton trigger, mais tu peux éventuellement remplacer le rollback transaction en cas d'erreur dans le trigger par un rollback trigger qui n'affectera que les modifications impliquées par le trigger :
Triggers and transactions
When a trigger is defined, the action it specifies on the table to which it applies is always implicitly part of a transaction, along with the trigger itself. Triggers are often used to roll back an entire transaction if an error is detected, or they can be used roll back the effects of a specific data modification:
o When the trigger contains the rollback transaction command, the rollback aborts the entire batch, and any subsequent statements in the batch are not executed.
o When the trigger contains the rollback trigger, the rollback affects only the data modification that caused the trigger to fire. The rollback trigger command can include a raiserror statement. Subsequent statements in the batch are executed.
Hors ligne










buck a écrit:
Bonjour,
Je ne connais pas le contenu et la structure de ton trigger, mais tu peux éventuellement remplacer le rollback transaction en cas d'erreur dans le trigger par un rollback trigger qui n'affectera que les modifications impliquées par le trigger :Triggers and transactions
When a trigger is defined, the action it specifies on the table to which it applies is always implicitly part of a transaction, along with the trigger itself. Triggers are often used to roll back an entire transaction if an error is detected, or they can be used roll back the effects of a specific data modification:
o When the trigger contains the rollback transaction command, the rollback aborts the entire batch, and any subsequent statements in the batch are not executed.
o When the trigger contains the rollback trigger, the rollback affects only the data modification that caused the trigger to fire. The rollback trigger command can include a raiserror statement. Subsequent statements in the batch are executed.
on fait cela comment ?
tu as un exemple ?
c'est pour quelle type de base de donnée ?
Hors ligne






Bonjour,
Pour sauvegarder une ligne insérée dans une table malgré une erreur dans le trigger (ASE 12.5.1), on peut procéder de cette manière :
CREATE TRIGGER dbo.trg_demo ON dbo.enumeres For INSERT AS begin save transaction beforetrigger insert into pays values('FRA','France') if (@@error != 0) begin rollback transaction beforetrigger end commit transaction end
J'ai lu un peu vite en transversal le rollback trigger annule également l'insertion de la ligne ayant déclenché le trigger, mais pas l'ensemble des autres formulations SQL faisant partie de la même transaction contrairement au rollback transaction.
Hors ligne