pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedecpg: HOW TO READ RECORD ??
2+ messages / 2 participants
[nested] [flat]
* ecpg: HOW TO READ RECORD ??
@ 2007-08-23 14:55 Roger Moloney <ramoloney@hotmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Roger Moloney @ 2007-08-23 14:55 UTC (permalink / raw)
To: pgsql-interfaces
Hi,
We use ecpg (embedded sql) and plpgsql (postgres functions).
I'm having trouble trying to get embedded SQL to read the result of a
plpgsql function which returns RECORD or SETOF RECORD.
Does anyone have an example of this ? I don't see it in the ecpg source
examples or in the ecpg manual.
/* following is an example of plpgsql to illustrate the data being returned
*/
/* type defined for the record that the function will return to avoid using
column list */
create type tp_GetPerson as (
person_name char(40),
person_age smallint
);
/* this function returns zero or more tp_GetPerson records */
create function p_GetPersonByDept (pperson_dept integer)
returns SETOF tp_GetPerson as
$$
declare
v_record tp_GetPerson%ROWTYPE;
begin
for v_record in
select person_name, person_age from person where person_dept =
pperson_dept
loop
return next v_record;
end loop;
return;
end
$$
language 'plpgsql';
WHAT SHOULD THE ECPG PROGRAM LOOK LIKE THAT CAN READ THE DATA RETURNED ?
thanks,
RML
_________________________________________________________________
Download the latest version of Windows Live Messenger NOW!
http://get.live.com/en-za/messenger/overview
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ecpg: HOW TO READ RECORD ??
@ 2007-08-25 09:21 Michael Meskes <meskes@postgresql.org>
parent: Roger Moloney <ramoloney@hotmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meskes @ 2007-08-25 09:21 UTC (permalink / raw)
To: Roger Moloney <ramoloney@hotmail.com>; +Cc: pgsql-interfaces
On Thu, Aug 23, 2007 at 02:55:10PM +0000, Roger Moloney wrote:
> I'm having trouble trying to get embedded SQL to read the result of a
> plpgsql function which returns RECORD or SETOF RECORD.
> ...
> WHAT SHOULD THE ECPG PROGRAM LOOK LIKE THAT CAN READ THE DATA RETURNED ?
Any reason to shout? :-)
You call that function with a select, right? So where's the difference
between the handling of a "normal" select that returns more than one
tuple (e.g. in preproc/define.pgc) and yours?
Or what am I misunderstanding here?
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-08-25 09:21 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-08-23 14:55 ecpg: HOW TO READ RECORD ?? Roger Moloney <ramoloney@hotmail.com>
2007-08-25 09:21 ` Michael Meskes <meskes@postgresql.org>
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