Hello!
I have a problem in creating a trigger in mysql using UniQuery Component:
CREATE TRIGGER trtest BEFORE UPDATE OF test FOR EACH ROW
BEGIN
SET NEW.Datum = CURRENT_TIMESTAMP;
END;
After reading some examples of creating triggers in MySQL I realized, that always a special delimiter was declared:
DELIMITER //
CREATE TRIGGER ...
END;//
In SQL Workbench I must use this DELIMITER clause to create the trigger or an error occurs. How can I create a trigger using UniQuery in MySQL?
Thx
Moehre
Creating Trigger in MySQL
To create a trigger using TUniQuery you should only set the SQL property to appropriate SQL statement and call the Execute method, like this:
Code: Select all
UniQuery1.SQL.Clear;
UniQuery1.SQL.Add('CREATE TRIGGER trtest BEFORE UPDATE ON test FOR EACH ROW ');
UniQuery1.SQL.Add('BEGIN ');
UniQuery1.SQL.Add('SET NEW.Datum = CURRENT_TIMESTAMP; ');
UniQuery1.SQL.Add('END;');
UniQuery1.Execute;