dimanche 12 janvier 2020

Set Value to Variable in MySQL Trigger

I Create a MySql trigger and declare a variable. then i have some if condition. inside if cannot be set values to that declared variable out side of if. it's Possible? because i need that variable data to another functions. i'm always getting null.

This is my sample code Setting Query get value when it Execute

delimiter $$
CREATE TRIGGER Table1INSERTCustomer
    AFTER INSERT ON Table1
    FOR EACH ROW

BEGIN

DECLARE CustomerId integer;

IF (SELECT CustomerID FROM Seller WHERE Id = NEW.ResellerID AND CustomerID IS NOT NULL) 
THEN 
BEGIN

SET @CustomerId := (SELECT CustomerID FROM Seller WHERE Id = NEW.ResellerID LIMIT 1); <-- This is Problem

END; 
END IF;

END; 
$$ 

Thank You Very Much

Aucun commentaire:

Enregistrer un commentaire