Skip site navigation (1) Skip section navigation (2)

Re: Returning more than one value from a stored procedure

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Returning more than one value from a stored procedure
Date: 2010-07-08 11:13:40
Message-ID: 20100708111340.GI25665@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-novice
In response to Atif Jung :
> Thanks Andreas but is there no alternative?
>  
> I'm porting from an INFORMIX database which allows the return of more than one
> value from a stored procedure without having to use in/out parameters. The
> procedure is called from several places across the system and will be time
> consuming to change all instances to include the new out parameters. To be able
> to return more than one parameter will be of great help to me, if it's
> possible.

Other solution, but new problem for you:

test=# create or replace function atif(int, text) returns record as
$$declare r record; begin select into r 1::int, 'hello world'::text; return r; end;$$language plpgsql;
CREATE FUNCTION
test=*# select * from atif (0,'test') as foo(a int, b text);
 a |      b
---+-------------
 1 | hello world
(1 row)

test=*# select * from atif (0,'test');
ERROR:  a column definition list is required for functions returning "record"
LINE 1: select * from atif (0,'test');


Now you have to define the result-type later, but you have to define
that.

Regards, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

In response to

pgsql-novice by date

Next:From: Thomas KellererDate: 2010-07-08 11:43:58
Subject: Re: Returning more than one value from a stored procedure
Previous:From: Siddharth SahaDate: 2010-07-08 10:52:02
Subject: how to change line terminator

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group