Function Returning a Set of Composite Value

From: Nikhil teltia <nikhil_526(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Function Returning a Set of Composite Value
Date: 2009-02-03 00:06:08
Message-ID: 1504.3662.qm@web110406.mail.gq1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi All ,
I have a function f_wrapper(seq,pat) which returns a composite value of type (int,int[][]);
I am aware that I can run a query somthing like this to get it working

select * from f_wrapper('XYZ,'X') as m1(mid int,match int[][]);

but I want to pass another table column as parameter to function. - select f_wrapper( t.seq,'X') from t_sequence t;
this return result which looks like -

(0,"{{0,2,2}}")
(1,"{{10,2,2}}")

when I try to parse this result in following way -
select f_wrappwe(t.seq,'X') frm t_sequence t as m1(mid int,match int[][]) ; I get following syntax error

ERROR: syntax error at or near "int"
LINE 1: ...f_wrapper(seq,'MK') from nik_small_file as m1(mid int,match ...
^
any idea why I am getting this error or what is the alternative to parse composite value in select column ?

my
purpose is to to show some column from table+(result from f_wrapper
function) but I am not able to parse f_wrapper result in required
column without calling f_wrapper twice like this -
select (f_wrapper(seq,'MK')).mid , (f_wrapper(seq,'MK')).match from nik_small_file;

since my f_wrapper is going to be a heavy function so I can't afford to call it twice.
any suggestion regarding this will be helpful.

Regards,
Nikhil

PS: Earlier I have sent same question to pgsql-novice as well but then I realised that this might be more relevant on this list. sorry for posting it twice.

Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/

Browse pgsql-sql by date

  From Date Subject
Next Message Jasen Betts 2009-02-04 09:59:08 Re: regexp_replace and UTF8
Previous Message Bart Degryse 2009-02-02 08:38:09 Re: regexp_replace and UTF8