>>"Fernando Hevia" <[EMAIL PROTECTED]> 2007-06-26 16:25 >>> >>How do I refer a specific field of the returned row from outside the >>function? How should I write the query in order to show only fields 1 and 3, for example?
>In case you would like to use set returning functions... > >if your function will return records with the same structure as an existing >table >CREATE FUNCTION my_func() RETURNS SETOF my_table AS ... > >if not you have to define the returning type >CREATE TYPE func_row AS ("field1" varchar(10), "field2" integer, "field3" >integer, ...) >CREATE FUNCTION my_func() RETURNS SETOF func_row AS ... > >now you can use your function >SELECT * FROM my_func(); > >or > >SELECT A.field1, A.field2 >FROM my_func() A left join my_func() B on A.field2 = B.field3 >WHERE A.field1 like 'B%'; Exactly what I was looking for. Thanks!! ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org