pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFUNCTIONS PROBLEM
3+ messages / 3 participants
[nested] [flat]
* FUNCTIONS PROBLEM
@ 2003-03-20 22:25 Mario Alberto Soto Cordones <mario_soto@compuall.cl>
0 siblings, 0 replies; 3+ messages in thread
From: Mario Alberto Soto Cordones @ 2003-03-20 22:25 UTC (permalink / raw)
To: pgsql-sql
Hi.
i have a function and i need to return 4 fields but not work,
any idea , please
thank
mario
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: FUNCTIONS PROBLEM
@ 2003-03-23 23:18 David Witham <davidw@unidial.com.au>
0 siblings, 1 reply; 3+ messages in thread
From: David Witham @ 2003-03-23 23:18 UTC (permalink / raw)
To: Mario Alberto Soto Cordones <mario_soto@compuall.cl>; pgsql-sql
Hi Mario,
I have used a record type to do this:
create myfunc() returns record as '
declare
return_val record;
col1 int;
col2 int;
col3 real;
col4 char;
col1 := 5;
col2 := 10;
col3 := 2.7;
col4 := ''z'';
select col1,col2,col3,col4 into return_val;
return return_val;
end;
' language 'plpgsql';
When you call the function you need to specify the expected output:
select * from myfunc() as (val1 int, val2 int, val3 real, val4 char);
See the SELECT reference page in the documentation.
There are other ways (which may be better) to do this that don't require the output types to be specified with the query but this is the one I got going first so I stuck with it. Hope this helps.
Regards,
David Witham
Telephony Platforms Architect
Unidial
-----Original Message-----
From: Mario Alberto Soto Cordones [mailto:mario_soto@compuall.cl]
Sent: Friday, 21 March 2003 09:26
To: pgsql-sql@postgresql.org
Subject: [SQL] FUNCTIONS PROBLEM
Importance: High
Hi.
i have a function and i need to return 4 fields but not work,
any idea , please
thank
mario
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: FUNCTIONS PROBLEM
@ 2003-03-24 04:43 Rajesh Kumar Mallah <mallah@trade-india.com>
parent: David Witham <davidw@unidial.com.au>
0 siblings, 0 replies; 3+ messages in thread
From: Rajesh Kumar Mallah @ 2003-03-24 04:43 UTC (permalink / raw)
To: David Witham <davidw@unidial.com.au>; Mario Alberto Soto Cordones <mario_soto@compuall.cl>; pgsql-sql
CREATE TYPE can be used as well i think
in that case "as (val1 int, val2 int, val3 real, val4 char);"
need not be done while selecting.
regds
mallah
On Monday 24 Mar 2003 4:48 am, David Witham wrote:
> Hi Mario,
>
> I have used a record type to do this:
>
> create myfunc() returns record as '
>
> declare
> return_val record;
> col1 int;
> col2 int;
> col3 real;
> col4 char;
>
> col1 := 5;
> col2 := 10;
> col3 := 2.7;
> col4 := ''z'';
>
> select col1,col2,col3,col4 into return_val;
> return return_val;
> end;
> ' language 'plpgsql';
>
> When you call the function you need to specify the expected output:
>
> select * from myfunc() as (val1 int, val2 int, val3 real, val4 char);
>
> See the SELECT reference page in the documentation.
>
> There are other ways (which may be better) to do this that don't require
> the output types to be specified with the query but this is the one I got
> going first so I stuck with it. Hope this helps.
>
> Regards,
> David Witham
> Telephony Platforms Architect
> Unidial
>
> -----Original Message-----
> From: Mario Alberto Soto Cordones [mailto:mario_soto@compuall.cl]
> Sent: Friday, 21 March 2003 09:26
> To: pgsql-sql@postgresql.org
> Subject: [SQL] FUNCTIONS PROBLEM
> Importance: High
>
>
> Hi.
>
> i have a function and i need to return 4 fields but not work,
>
> any idea , please
>
> thank
>
> mario
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)
Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-03-24 04:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-20 22:25 FUNCTIONS PROBLEM Mario Alberto Soto Cordones <mario_soto@compuall.cl>
2003-03-23 23:18 Re: FUNCTIONS PROBLEM David Witham <davidw@unidial.com.au>
2003-03-24 04:43 ` Rajesh Kumar Mallah <mallah@trade-india.com>
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