Re: : Postgres order by into a RECORD, not ordering

Started by Shaun Clementsabout 21 years ago4 messagesgeneral
Jump to latest
#1Shaun Clements
ShaunC@relyant.co.za

Hi Again.

I hope you can explain this.
I have a stored procedure which does a query of a table using order by, into
a RECORD.
The statement I mentioned earlier, is a FOR IN.
the data stored into the RECORD, is not ordered by the columns specified,
because when I loop through the record, the columns returned in the row are
different, to when I manually do a Select query using order by.
I assumed this may have something to do with the index.

Is there any reason why this is so ?

Kind Regards,
Shaun Clements

#2Shaun Clements
ShaunC@relyant.co.za
In reply to: Shaun Clements (#1)

RESOLVED.

It must be a bug in 7.3
I resolved the problem, by changing the FOR IN statement to FOR IN EXECUTE.
By changing the Statement into a string, it accommodated for the ORDER BY.

Thanks for all your responses.

Kind Regards,
Shaun Clements

-----Original Message-----
From: Shaun Clements
Sent: 01 April 2005 12:22 PM
To: 'Richard Huxton'
Cc: PostgreSQL General
Subject: RE: : [GENERAL] Postgres order by into a RECORD, not ordering

Hi Again.

I hope you can explain this.
I have a stored procedure which does a query of a table using order by, into
a RECORD.
The statement I mentioned earlier, is a FOR IN.
the data stored into the RECORD, is not ordered by the columns specified,
because when I loop through the record, the columns returned in the row are
different, to when I manually do a Select query using order by.
I assumed this may have something to do with the index.

Is there any reason why this is so ?

Kind Regards,
Shaun Clements

#3Shaun Clements
ShaunC@relyant.co.za
In reply to: Shaun Clements (#2)

Ignore last email.
must have been delayed.

Kind Regards,
Shaun Clements

-----Original Message-----
From: Shaun Clements [mailto:ShaunC@relyant.co.za]
Sent: 01 April 2005 12:22 PM
To: 'Richard Huxton'
Cc: PostgreSQL General
Subject: Re: : [GENERAL] Postgres order by into a RECORD, not ordering

Hi Again.

I hope you can explain this.
I have a stored procedure which does a query of a table using order by, into
a RECORD.
The statement I mentioned earlier, is a FOR IN.
the data stored into the RECORD, is not ordered by the columns specified,
because when I loop through the record, the columns returned in the row are
different, to when I manually do a Select query using order by.

I assumed this may have something to do with the index.

Is there any reason why this is so ?

Kind Regards,
Shaun Clements

#4Michael Fuhr
mike@fuhr.org
In reply to: Shaun Clements (#2)

On Fri, Apr 01, 2005 at 12:36:53PM +0200, Shaun Clements wrote:

RESOLVED.

It must be a bug in 7.3

Before reaching that conclusion, let's see what you were doing.

I resolved the problem, by changing the FOR IN statement to FOR IN EXECUTE.
By changing the Statement into a string, it accommodated for the ORDER BY.

Could you post the code that didn't work and the code that does
work? There might be a better solution than what you did. In any
case, it's good to understand *why* something doesn't work, so if
you post the code then maybe somebody can explain what's wrong.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/