不需要分隔符语句。Play 会将您的文件拆分为多个查询,其中一个文件以“;”结尾 特点。
如果你想创建一个复杂的触发器,你不想在分号后分割你的文件,所以你用双分号“;;”转义它。
您以一个分号结束每个查询,并在触发器内以双分号结束您的查询。
例子 :
DROP TRIGGER IF EXISTS invoice_line_insert;
CREATE TRIGGER invoice_line_insert AFTER INSERT
ON invoice_line FOR EACH ROW
BEGIN
IF NEW.type = "DELIVERY" THEN
UPDATE invoice
SET invoice.etdelivery_amount = invoice.etdelivery_amount + NEW.amount
WHERE invoice.id_invoice = NEW.invoice_parent_id_invoice;;
ELSE
UPDATE invoice
SET invoice.etexpense_amount = invoice.etexpense_amount + NEW.amount
WHERE invoice.id_invoice = NEW.invoice_parent_id_invoice;;
END IF;;
UPDATE invoice
SET invoice.vatamount = (NEW.amount * (
SELECT vat.rate
FROM vat
WHERE vat.id_vat = NEW.vat_id_vat
)) + invoice.vatamount
WHERE invoice.id_invoice = NEW.invoice_parent_id_invoice;;
UPDATE invoice
SET invoice.itamount = invoice.vatamount +
invoice.etdelivery_amount +
invoice.etexpense_amount
WHERE invoice.id_invoice = NEW.invoice_parent_id_invoice;;
END;