Good day,
I'm having trouble with my query, as I can't seem to understand why I keep getting the error "syntax error at or near "AS" here's my query:
CREATE TRIGGER updateAvailableQuantity
AFTER INSERT ON sale_item FOR EACH ROW
AS $$
BEGIN
IF NEW.quantity > 0 THEN
UPDATE products
SET products.quantity_instock = products.quantity_instock - NEW.quantity WHERE barcode = NEW.barcode;
END IF;
END;
$$ LANGUAGE plpgsql;
the error that I keep getting is,
ERROR: syntax error at or near "AS"
LINE 4: AS $$
^
SQL state: 42601
Character: 100