Subject | Re: [firebird-support] How to evaluate expression to field value |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2008-03-01T13:00:16Z |
I would simply have done
VAL_RESULT = NEW.SUM1
if (NEW.MONTH >= 2) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM2
if (NEW.MONTH >= 3) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM3
if (NEW.MONTH >= 4) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM4
if (NEW.MONTH >= 5) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM5
if (NEW.MONTH >= 6) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM6
if (NEW.MONTH >= 7) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM7
if (NEW.MONTH >= 8) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM8
if (NEW.MONTH >= 9) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM9
if (NEW.MONTH >= 10) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM10
if (NEW.MONTH >= 11) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM11
if (NEW.MONTH = 12) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM12
I would be somewhat surprised if NEW. and OLD. was accessible if used as
part of the string called by EXECUTE STATEMENT, but I must admit that I
do not know.
Set
Mr. John wrote:
VAL_RESULT = NEW.SUM1
if (NEW.MONTH >= 2) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM2
if (NEW.MONTH >= 3) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM3
if (NEW.MONTH >= 4) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM4
if (NEW.MONTH >= 5) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM5
if (NEW.MONTH >= 6) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM6
if (NEW.MONTH >= 7) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM7
if (NEW.MONTH >= 8) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM8
if (NEW.MONTH >= 9) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM9
if (NEW.MONTH >= 10) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM10
if (NEW.MONTH >= 11) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM11
if (NEW.MONTH = 12) THEN
VAL_RESULT = VAL_RESULT+NEW.SUM12
I would be somewhat surprised if NEW. and OLD. was accessible if used as
part of the string called by EXECUTE STATEMENT, but I must admit that I
do not know.
Set
Mr. John wrote:
> Hi !
> I have one table withe some fields like this ...sum_1,sum2...sum_12 for every month.
> Inside of a trigger (before trigger) I need to get some of these for a given month-value
>
> I=0;VAL_RESULT=0;
> WHILE (I<=NEW.MONTH) DO BEGIN
> VAL_RESULT=VAL_RESULT+NEW.SUM_'||I;
> I=I+1;
> END
> EXECUTE PROCEDURE MYPROC(VAL_RESULT) ;
>
> or i have to use EXECUTE STATEMENT and get values directly from database
>
> Thanks a lot.