[SQL]

2008-11-05 Thread Hemant Patel
Hello Everyone,

I have a array of ids from my search result and now I want to 
fetch the details from the database.
Now IN query is ruined my sort order.So should I go for Union All?
Is there any other method to fetch the data..?

Please help me in this
Thanks in advance...

With Regards,
Hemant Patel



NOTE: This message may contain information that is confidential, proprietary, 
privileged or otherwise protected by law. The message is intended solely for 
the named addressee. If received in error, please destroy and notify the 
sender. Any use of this email is prohibited when received in error. Impetus 
does not represent, warrant and/or guarantee, that the integrity of this 
communication has been maintained nor that the communication is free of errors, 
virus, interception or interference.

Impetus is the winner of the Economic Times Intel Smart Workplace Awards 2008 
and the CNBC emerging India 2008. Visit www.impetus.com for details.


Re: [SQL] Display message to user

2008-11-05 Thread Peter Eisentraut

Bart van Houdt wrote:
Oracle has a nice package procedure (dbms_output.put_line) to display a 
message in SQL*Plus, which can display a message to the user. I use this 
a lot, to notify users of the progress being made during the execution 
of a script.


Is there a way to do this with Postgres as well?


If you use the orafce module from pgfoundry, you get that same function.


--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL]

2008-11-05 Thread ries van Twisk


On Nov 5, 2008, at 8:42 AM, Hemant Patel wrote:


Hello Everyone,

I have a array of ids from my search result and now  
I want to fetch the details from the database.

Now IN query is ruined my sort order.So should I go for Union All?


IN doesn't ruin your sort order really You need to think in sets...


Is there any other method to fetch the data..?


Can't you not directly join against you other table to fetch the  
result directly??


Show us the SQL you are working with + tables would help aswell.




Please help me in this….
Thanks in advance…

With Regards,
Hemant Patel














Re: [SQL]

2008-11-05 Thread Hemant Patel
Let Say I have the array of primary key of some table say XYZ.
For e.g. (555,222,333,111)

When I query for these results I will get the result like  in the order of 
(111,222,333,555) .
So now I need to process in the business logic to maintain the search criteria.

But I want the result from IIN query...  the order I provide the ids

And if I will make query like ,
select * from XYZ where id=555 UNION ALL select * from XYZ where id=222 etc
Then it will return in that order.

so which one is better approach,
Or is there any other way...?

With Regards,
Hemant Patel
From: ries van Twisk [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 05, 2008 8:21 PM
To: Hemant Patel
Cc: pgsql-sql
Subject: Re: [SQL]


On Nov 5, 2008, at 8:42 AM, Hemant Patel wrote:


Hello Everyone,

I have a array of ids from my search result and now I want to 
fetch the details from the database.
Now IN query is ruined my sort order.So should I go for Union All?

IN doesn't ruin your sort order really You need to think in sets...


Is there any other method to fetch the data..?

Can't you not directly join against you other table to fetch the result 
directly??

Show us the SQL you are working with + tables would help aswell.




Please help me in this
Thanks in advance...

With Regards,
Hemant Patel












NOTE: This message may contain information that is confidential, proprietary, 
privileged or otherwise protected by law. The message is intended solely for 
the named addressee. If received in error, please destroy and notify the 
sender. Any use of this email is prohibited when received in error. Impetus 
does not represent, warrant and/or guarantee, that the integrity of this 
communication has been maintained nor that the communication is free of errors, 
virus, interception or interference.

Impetus is the winner of the Economic Times Intel Smart Workplace Awards 2008 
and the CNBC emerging India 2008. Visit www.impetus.com for details.


Re: [SQL]

2008-11-05 Thread Scott Marlowe
On Wed, Nov 5, 2008 at 9:21 AM, Hemant Patel <[EMAIL PROTECTED]> wrote:
> Let Say I have the array of primary key of some table say XYZ.
>
> For e.g. (555,222,333,111)
>
>
>
> When I query for these results I will get the result like  in the order of
> (111,222,333,555) .
>
> So now I need to process in the business logic to maintain the search
> criteria.

The fact that you get results in a certain order without using an
order by clause is a happy coincidence, and not to be relied upon.
Should PostgreSQL choose a different query plan they may come back in
some other order.

I.e. you HAVE to use an order by clause if you want a certain order.  period.

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql