Subject FB 2.0 Road Map
Author Alexandre Benson Smith
Hi !

I have read th FB 2.0 RoadMap, and wish to ask for a feature request.

I have discussed this on firebird-support some time ago.

What I think could be implemented in FB is a UPDATED function that will
run insed triggers, this function will be used to test if a column was
modified.

In triggers I use to do this

If (
(Old.Quantity <> New.Quantity) or
((Old.Quantity is null) and (New.Quantity is not null)) or
((Old.Quantity is not null) and (New.Quantity is null))
) then

This will be changed by

if Updated(ColumnA) then

in delete or insert triggers UPDATED always return true, and in update
triggers should work as above.

The readability is, IMHO, very increased, mainly when one wish to test
multiple columns like this

if (Updated(Quantity) or Updated(Price) or Updated(Discount)) then
SP_SalesItemCalcNetValue(new.SalesItemID)

that is far more simple, less suitable for errors and easier to read
than the actual version that is
if (
(Old.Quantity <> New.Quantity) or
((Old.Quantity is null) and (New.Quantity is not null)) or
((Old.Quantity is not null) and (New.Quantity is null)) or

(Old.Price <> New.Price) or
((Old.Price is null) and (New.Price is not null)) or
((Old.Price is not null) and (New.Price is null)) or

(Old.Discount <> New.Discount) or
((Old.Discount is null) and (New.Quantity is not null)) or
((Old.Discount is not null) and (New.Discount is null))
) then
SP_SalesItemCalcNetValue(new.SalesItemID)


Now, with Coalesce this could be simplified to:

if (
(Coalesce(Old.Quantity, -9999 ) <> Coalesce(New.Quantity, -9999) or
(Coalesce(Old.Price, -9999 ) <> Coalesce(New.Price, -9999) or
(Coalesce(Old.Discount, -9999 ) <> Coalesce(New.Discount, -9999)
) then
SP_SalesItemCalcNetValue(new.SalesItemID)

Only if you are sure that the value -9999 will never be a valid values
for the tested columns...

Anyone think this could be done ?
Is this a simple thing to do ?

see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br