From: | "Rodríguez Rodríguez, Pere" <prr(at)hosppal(dot)es> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | return two elements |
Date: | 2005-06-06 14:45:54 |
Message-ID: | B35596C2EFF3D2118EE100A0C94B2A60014BFBDC@palamos_nt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
how can I write a function that return two or more elements?
I try to return a record but after I don't know how to assign returned value
to a variable. For example,
CREATE OR REPLACE FUNCTION test1() RETURNS record AS '
declare
rec record;
begin
select into rec \'01/01/2005\'::Date as dt_inici,
\'02/02/2005\'::Date as dt_fi;
return rec;
end; '
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION test2() RETURNS date AS '
declare
rec record;
begin
-- rec := test1(); << ERROR: syntax error at
or near "rec"
select into rec test1();
return rec.dt_inici; << ERROR: record "rec" has no field
"dt_inici"
end; '
LANGUAGE 'plpgsql' VOLATILE;
Can I return an array?, and how I take returned array?
I search postgres documentation but I don't find it
Thanks in advance,
pere
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-06-06 14:56:15 | Re: pg_dump 8.0.3 failing against PostgreSQL 7.3.2 |
Previous Message | John Sidney-Woollett | 2005-06-06 14:21:34 | Re: Download mirrors not found? |