Re: FUNCTIONS PROBLEM

From: "David Witham" <davidw(at)unidial(dot)com(dot)au>
To: "Mario Alberto Soto Cordones" <mario_soto(at)compuall(dot)cl>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: FUNCTIONS PROBLEM
Date: 2003-03-23 23:18:27
Message-ID: CFA248776934FD43847E740E43C346D1379688@ozimelb03.ozicom.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)compuall(dot)cl]
Sent: Friday, 21 March 2003 09:26
To: pgsql-sql(at)postgresql(dot)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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2003-03-24 04:43:37 Re: FUNCTIONS PROBLEM
Previous Message mallah 2003-03-22 18:30:35 Re: newline character in SQL