Home > Archive > PostgreSQL Discussion > September 2005 > regarding select into









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author regarding select into
surabhi.ahuja

2005-09-26, 3:23 am

Hello,

Is it not possible to write such an sql statement:

select ser into val1, count(*) into val2 from tab1 where id = $1;

do i need to perform the 2 selects separately ..wont that impact the performance?

in the table tab1, id is the primary key.

Thank You

Regards
Surabhi Ahuja

Alban Hertroys

2005-09-26, 7:23 am

surabhi.ahuja wrote:
> Hello,
>
> Is it not possible to write such an sql statement:
>
> select ser into val1, count(*) into val2 from tab1 where id = $1;
>
> do i need to perform the 2 selects separately ..wont that impact the
> performance?


Well, considering id is your primary key and therefore very probably
unique, you could as well do: select ser, 1 from tab1 where id=$1;

Otherwise, whatever interface you're using is likely to have a rowcount
value for you.
If that's not what you're looking for, please don't make us guess what
you want to achieve.

--
Alban Hertroys
alban@magproductions
.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

//Showing your Vision to the World//

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Rolf Østvik

2005-09-27, 3:23 am

surabhi.ahuja@iiitb.ac.in ("surabhi.ahuja") wrote in
news:967CFC4343BF2A4
DAFACD026D33DC85118E
C70@jal.iiitb.ac.in:

> Hello,
>
> Is it not possible to write such an sql statement:
>
> select ser into val1, count(*) into val2 from tab1 where id = $1;
>
> do i need to perform the 2 selects separately ..wont that impact the

performance?
>
> in the table tab1, id is the primary key.
>


Pleas don't attach html to your e-mails.
(Normally you should be able to turn that functionality off).

Your question might be unclear.
I might be wrong but is it a PG/pgSQL funtion you are writing?

In that case i think you can use:

select into val1,val2 ser,count(*) from tab1 where id = $1;

(found in chapter "37.6.2 Select into" in my 7.4.2 documentation:

--
Rolf
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com