Re: syntax question - Mailing list pgsql-sql

From Josh Berkus
Subject Re: syntax question
Date
Msg-id 200302231452.00484.josh@agliodbs.com
Whole thread Raw
In response to syntax question  ("James Cooper" <jim@luckydigital.com>)
List pgsql-sql
James,

> FOR total IN EXECUTE subquery LOOP
>
> END LOOP;
>
> RETURN total.tot;

The above is fine, except that you need to assign total.tot to a variable
*inside* the loop:

FOR total IN EXECUTE subquery LOOPreturn_total := total.tot;
END LOOP;

RETURN return_total;

This is because the expression "total.tot" is out of scope as soon as the loop
exits.

--
Josh Berkus
Aglio Database Solutions
San Francisco


pgsql-sql by date:

Previous
From: "James Cooper"
Date:
Subject: syntax question
Next
From: Josh Berkus
Date:
Subject: Re: SQL Statements question, why I get errors...