pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Eckermann <jeff_eckermann@yahoo.com>
To: Josh Berkus <josh@agliodbs.com>
To: James Cooper <jim@luckydigital.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: syntax question
Date: Mon, 24 Feb 2003 07:17:40 -0800 (PST)
Message-ID: <20030224151740.15417.qmail@web20805.mail.yahoo.com> (raw)
In-Reply-To: <200302231507.23831.josh@agliodbs.com>

--- Josh Berkus <josh@agliodbs.com> wrote:
>  you cannot select the results of
> a query directly into a 
> RECORD variable without a loop.
> 

Pardon??

kper=# create function test(integer) returns varchar
as 'declare stuff record; begin select * into stuff
from employee where empid =$1; return stuff.empnum;
end;' language 'plpgsql';
CREATE

kper=# select test(66664);
 test 
------
 3094
(1 row)

kper=# select empid, empnum from employee where empid
= 66664;
 empid | empnum 
-------+--------
 66664 | 3094
(1 row)

This functinality has been in pl/pgsql from early days
AFAIK.  Be aware that this only works reliably if you
have some way to be sure of what will be selected
("empid" is a unique column in this example), because
the second and later rows to be returned from the
query will be silently discarded.

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



view thread (7+ messages)  latest in thread

Message-ID: <20030224151740.15417.qmail@web20805.mail.yahoo.com>
Permalink:  ../20030224151740.15417.qmail@web20805.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030224151740.15417.qmail@web20805.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jeff_eckermann@yahoo.com, josh@agliodbs.com, jim@luckydigital.com
  Subject: Re: syntax question
  In-Reply-To: <20030224151740.15417.qmail@web20805.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox