Subject RE: [firebird-support] How to call stored procedure from trigger
Author Leyne, Sean
> How do I correct the following trigger? It's complaining about the
> EXECUTE PROCEDURE part.
>
> DECLARE VARIABLE PO_ID BIGINT;
> DECLARE VARIABLE INV_ID BIGINT;
> begin
> /* create new/find existing PO and invoice */
> PO_ID = EXECUTE PROCEDURE P_CREATE_PO(NEW.PO, NEW.DIST_CTR,
> NEW.NABPNUM, NEW.GRANTEE, NEW.SUBMITTED);

EXECUTE PROCEDURE P_CREATE_PO(NEW.PO, NEW.DIST_CTR, NEW.NABPNUM,
NEW.GRANTEE, NEW.SUBMITTED) RETURNING_VALUES PO_ID;


> INV_ID = EXECUTE PROCEDURE P_CREATE_INVOICE(NEW.PO, NEW.INVOICE);

EXECUTE PROCEDURE P_CREATE_INVOICE(NEW.PO, NEW.INVOICE) RETURNING_VALUES
INV_ID;

>
> /* create order-item record */
> INSERT INTO ORDER_ITEM(PURCH_ORDER, NDC, QTY, INVOICE, DIST_CTR,
> STATUS, STATUS_CHNG)
> VALUES (:PO_ID, COALESCE(NEW.NDC_SUB, NEW.NDC),
> COALESCE(NEW.QTY_SHIP_SUB, NEW.QTY_SHIPPED), :PO_ID, NEW.DIST_CTR,
'O',
> NEW.SUBMITTED);
> end