record to columns: syntax question and strange behaviour - Mailing list pgsql-sql

From Marc Mamin
Subject record to columns: syntax question and strange behaviour
Date
Msg-id C4DAC901169B624F933534A26ED7DF31010A5364@JENMAIL01.ad.intershop.net
Whole thread Raw
Responses Re: record to columns: syntax question and strange behaviour  (Thomas Pundt <mlists@rp-online.de>)
List pgsql-sql
<p><font face="Arial" size="2">Hello,</font><p><font face="Arial" size="2">how should I retrieve the result from a
functionwith some OUT paramenters?</font><p><font face="Arial" size="2">(PG is  8.3.7)</font><p><font face="Arial"
size="2">herea short example to illustrate my question:</font><p><font face="Arial" size="2">CREATE OR REPLACE FUNCTION
test(In a int, OUT b int, OUT c int) AS</font><br /><font face="Arial" size="2">$BODY$</font><br /><font face="Arial"
size="2">BEGIN</font><br/><font face="Arial" size="2">  b:=a+1;</font><br /><font face="Arial" size="2"> 
c:=a+2;</font><br/><font face="Arial" size="2">  raise notice 'done: %', a;</font><br /><font face="Arial"
size="2">END</font><p><fontface="Arial" size="2">$BODY$</font><br /><font face="Arial" size="2">  LANGUAGE 'plpgsql'
IMMUTABLE</font><br/><br /><br /><p><font face="Arial" size="2">select column1, test(column1) FROM (values(1),(2))
foo</font><p><fontface="Arial" size="2">1, (2,3)</font><br /><font face="Arial" size="2">2, (3,4)</font><p><font
face="Arial"size="2">NOTICE:  done: 1</font><br /><font face="Arial" size="2">NOTICE:  done: 2</font><br /><p><font
face="Arial"size="2">What I want is just</font><p><font face="Arial" size="2">1,2,3</font><br /><font face="Arial"
size="2">2,3,4</font><br /><p><font face="Arial" size="2">Following returns the expected result, but the function is
calledfor each OUT parameter:</font><p><font face="Arial" size="2">select column1, (test(column1)).* FROM 
(values(1),(2))foo</font><p><font face="Arial" size="2">=> </font><p><font face="Arial" size="2">1,2,3</font><br
/><fontface="Arial" size="2">2,3,4 </font><p><font face="Arial" size="2">NOTICE:  done: 1</font><br /><font
face="Arial"size="2">NOTICE:  done: 1</font><br /><font face="Arial" size="2">NOTICE:  done: 2</font><br /><font
face="Arial"size="2">NOTICE:  done: 2</font><p><font face="Arial" size="2">Is there a way to avoid it ???</font><br
/><p><fontface="Arial" size="2">Thanks,</font><p><font face="Arial" size="2">Marc Mamin</font> 

pgsql-sql by date:

Previous
From: John
Date:
Subject: Re: trouble with getting the field names
Next
From: Thomas Pundt
Date:
Subject: Re: record to columns: syntax question and strange behaviour