Subject | prevent changes to invoice record |
---|---|
Author | Rick Roen |
Post date | 2005-10-31T19:27:34Z |
FB 1.5
I'm looking for some kind of general technique to prevent changes to
invoice records, except under certain conditions.
The general table setup is like this (abreviated for clarity):
Orders - fields INVOICENUM (PK), ORDER_DATE (not null), INVOICE_DATE
(can be null before being invoiced), TOTAL
OrderItems - fields IDNUM (PK), INVOICENUM, ITEMNUM, QTY_ORDER,
QTY_SHIP, PRICE
When an order is invoiced, the ORDERS.INVOICE_DATE is filled in and
the ORDERITEMS.QTY_SHIP * ORDERITEMS.PRICE is the value for
ORDERS.TOTAL.
Once the ORDERS.INVOICE_DATE is not null (i.e. Invoiced) I do not
want to allow changes except by the SYSDBA.
I know I can intercept any changes via a trigger in ORDERITEMS and
ORDERS, however in the case of ORDERITEMS I would have to check with
a select statement like this inside the trigger:
Select INVOICENUM from ORDERS where INVOICENUM = old.INVOICENUM and
INVOICE_DATE is not null
This seems like an expensive operation to call for each item in the
order since there might be several hundred items in an order and
several clients filling orders at the same time.
I'm sure this is something that others have faced something like
this. Is there a better way to prevent changes to an invoiced order?
Thanks,
Rick
I'm looking for some kind of general technique to prevent changes to
invoice records, except under certain conditions.
The general table setup is like this (abreviated for clarity):
Orders - fields INVOICENUM (PK), ORDER_DATE (not null), INVOICE_DATE
(can be null before being invoiced), TOTAL
OrderItems - fields IDNUM (PK), INVOICENUM, ITEMNUM, QTY_ORDER,
QTY_SHIP, PRICE
When an order is invoiced, the ORDERS.INVOICE_DATE is filled in and
the ORDERITEMS.QTY_SHIP * ORDERITEMS.PRICE is the value for
ORDERS.TOTAL.
Once the ORDERS.INVOICE_DATE is not null (i.e. Invoiced) I do not
want to allow changes except by the SYSDBA.
I know I can intercept any changes via a trigger in ORDERITEMS and
ORDERS, however in the case of ORDERITEMS I would have to check with
a select statement like this inside the trigger:
Select INVOICENUM from ORDERS where INVOICENUM = old.INVOICENUM and
INVOICE_DATE is not null
This seems like an expensive operation to call for each item in the
order since there might be several hundred items in an order and
several clients filling orders at the same time.
I'm sure this is something that others have faced something like
this. Is there a better way to prevent changes to an invoiced order?
Thanks,
Rick