| From: | "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de> |
|---|---|
| To: | <pgsql-sql(at)postgresql(dot)org> |
| Subject: | record to columns: syntax question and strange behaviour |
| Date: | 2009-10-27 16:08:07 |
| Message-ID: | C4DAC901169B624F933534A26ED7DF31010A5364@JENMAIL01.ad.intershop.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Hello,
how should I retrieve the result from a function with some OUT
paramenters?
(PG is 8.3.7)
here a short example to illustrate my question:
CREATE OR REPLACE FUNCTION test (In a int, OUT b int, OUT c int) AS
$BODY$
BEGIN
b:=a+1;
c:=a+2;
raise notice 'done: %', a;
END
$BODY$
LANGUAGE 'plpgsql' IMMUTABLE
select column1, test(column1) FROM (values(1),(2)) foo
1, (2,3)
2, (3,4)
NOTICE: done: 1
NOTICE: done: 2
What I want is just
1,2,3
2,3,4
Following returns the expected result, but the function is called for
each OUT parameter:
select column1, (test(column1)).* FROM (values(1),(2)) foo
=>
1,2,3
2,3,4
NOTICE: done: 1
NOTICE: done: 1
NOTICE: done: 2
NOTICE: done: 2
Is there a way to avoid it ???
Thanks,
Marc Mamin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Pundt | 2009-10-27 17:20:46 | Re: record to columns: syntax question and strange behaviour |
| Previous Message | John | 2009-10-27 02:02:55 | Re: trouble with getting the field names |