Subject Re: [firebird-support] Definig variable as a domain
Author Helen Borrie
At 05:13 PM 15/03/2010, you wrote:
>Thanx Helen. Can you clarify what is the difference between
>
>DECLARE VARIABLE RATE PERCENTAGE;
>and
>declare variable RATE TYPE OF PERCENTAGE;

PERCENTAGE is not a data type. The TYPE OF keyword signals to the engine that you want the variable to have the same data type as the data type of the named domain. Note that any constraints applicable to the domain do apply to the variable.

>I will try your approach.

Try reading the Fb 2.1 release notes, too.


>As for the actual calculation itself, I should have mentioned that the error happens in the SELECT query attempting to stick a value into :RATE

A parameter?


>But why would it work when called directly, vs a SELECT that runs the same proceudre via a COMPUTED BY column? Seems more to me to be a bug with COMPUTED columns.

A computed column must return a scalar. You should also be aware that a stored procedure is not a function.

You might be able to bend fortune by referring to the NEW context array (assuming that those arguments are columns in BUDGETENTRY):
ALTER TABLE BUDGETENTRY ADD TAXAMOUNT COMPUTED BY ((SELECT TAXAMOUNT FROM P_TAX_AMOUNT(new.TOTALVALUE_EXTAX, new.TAXRATEID)));

But I wouldn't hold my breath. You don't seem overly concerned about the likely precision errors you are laying into this SP. If you want a function, write a UDF.

./heLen