Re: order by in for loop in plpgsql does not work

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>, pgsql-general(at)postgresql(dot)org, pgpsql-bugs(at)postgresql(dot)org
Subject: Re: order by in for loop in plpgsql does not work
Date: 2002-11-27 05:10:55
Message-ID: 14334.1038373855@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> writes:
> I'd also say your problem was probably more due to how you are initialising
> exchangeno and routeno variables to empty strings and then using those values
> in the order by clause of the select.

Yes, this is surely the issue: the 'exchangeno' and 'routeno' names in
the ORDER BY clause are being replaced by the plpgsql vars of the same
names.

It's a bad idea to use plpgsql variable names that are the same as
column names of tables that you use in the function...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Christian Imbeault 2002-11-27 06:21:51 7.3RC2 createlang error
Previous Message Tom Lane 2002-11-27 04:47:15 Re: eXtreme PostgreSQL using system catalogs (was Turning off triggers ?)