Re: order by in for loop in plpgsql does not work - Mailing list pgsql-general

From Tom Lane
Subject Re: order by in for loop in plpgsql does not work
Date
Msg-id 14334.1038373855@sss.pgh.pa.us
Whole thread Raw
In response to Re: order by in for loop in plpgsql does not work  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List pgsql-general
"Nigel J. Andrews" <nandrews@investsystems.co.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: eXtreme PostgreSQL using system catalogs (was Turning off triggers ?)
Next
From: Jean-Christian Imbeault
Date:
Subject: 7.3RC2 createlang error