Skip site navigation (1) Skip section navigation (2)

Re: allowed variable names in functions?

From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: allowed variable names in functions?
Date: 2008-06-30 10:44:31
Message-ID: dbbf25900806300344o4cb6d6a9i9ba2beba8c668c60@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
By changing c2,c3,etc. to something else  xc2,xc3, etc. it worked!
So was the problem that I refered to the same names in the SELECT statement?


2008/6/30 A B <gentosaker(at)gmail(dot)com>:
> Then my assumption was wrong.
> Here is the entire function and it fails with the names
> c2,c2div,c3,c3div, but if names are changed, it works!
> (by works I mean I get the "hello" lines printed) There is nothing
> wrong with the select statement either, that works fine if I run it
> stand-alone, or with the names of c2,c2div,c3,c3div changed.
>
> CREATE OR REPLACE FUNCTION foo(pid_ INTEGER) RETURNS void AS $$
> DECLARE
>        c2 REAL;
>        c2div REAL;
>        c3 REAL;
>        c3div REAL;
> BEGIN
>        FOR tmp IN SELECT id,c2,c3 FROM Master  WHERE pid=pid_  AND c3 !=0 LOOP

In response to

Responses

pgsql-general by date

Next:From: A. KretschmerDate: 2008-06-30 10:48:04
Subject: Re: allowed variable names in functions?
Previous:From: A BDate: 2008-06-30 10:38:40
Subject: Re: allowed variable names in functions?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group