Function Returning a Set of Composite Value

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

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

Connect with friends all over the world. Get Yahoo! India Messenger at http://in.messenger.yahoo.com/?wm=n/

Browse pgsql-novice by date

  From Date Subject
Next Message Joe Conway 2009-02-03 02:31:30 Re: [NOVICE] LATIN2->UTF8 conversation with dblink
Previous Message rhubbell 2009-02-02 19:50:38 calculating elapsed times between timestamps