Subject | Re: [ib-support] Loop Problems and referencing to other tables |
---|---|
Author | Helen Borrie |
Post date | 2001-12-10T13:26:21Z |
At 10:11 AM 10-12-01 +0200, you wrote:
as
declare variable asum numeric(15,2); /* ''sum" is a keyword */
begin
FOR SELECT SUM(F1) FROM T1
WHERE F2 = :avariable
INTO :asum DO
BEGIN
UPDATE T2
SET F3 = :asum
WHERE F2 = :avariable;
END
END
regards,
Helen
>Suppose I have two tables, Table1(T1) and Table2 (T2), and 5 fields increate procedure summation (avariable integer) /* "variable" is a keyword */
>all tables, F1, F2, F3, F4, F5/*
>
>Select sum(F1) from T1 where T1.F2=variable into :sum;
>
>*/ Then I want to chek second table's second field (T2.F2) and for those
>records which value is equal to variable (i.e. for all records that
>T2.F2=:variable) I want to set the T2.F3 column with the value sum(T1.F1)/*
>
>For this the following loop is not excepted.
>
>While T2.F2=:variable do
>begin
>set T2.F3=:sum
>end
>suspend;
>end
>
>I thing there is someting wrong with my codation, But I do not know where is
>the error.
>Also I do not know how to reference the the other tables in a stored
>procedur
>Kursat
as
declare variable asum numeric(15,2); /* ''sum" is a keyword */
begin
FOR SELECT SUM(F1) FROM T1
WHERE F2 = :avariable
INTO :asum DO
BEGIN
UPDATE T2
SET F3 = :asum
WHERE F2 = :avariable;
END
END
regards,
Helen