Re: syntax question

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: "James Cooper" <jim(at)luckydigital(dot)com>, "sql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: syntax question
Date: 2003-02-23 22:52:00
Message-ID: 200302231452.00484.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 LOOP
return_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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-02-23 22:57:47 Re: SQL Statements question, why I get errors...
Previous Message plist 2003-02-23 22:17:53 SQL Statements question, why I get errors...