X-Original-To: pgsql-sql@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 92884924FE6 for ; Sun, 1 Jun 2003 00:08:21 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 00333-10 for ; Sun, 1 Jun 2003 00:08:11 -0400 (EDT) Received: from hotmail.com (f58.sea2.hotmail.com [207.68.165.58]) by developer.postgresql.org (Postfix) with ESMTP id 03AB592595D for ; Sun, 1 Jun 2003 00:02:27 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sat, 31 May 2003 21:02:22 -0700 Received: from 24.112.20.116 by sea2fd.sea2.hotmail.msn.com with HTTP; Sun, 01 Jun 2003 04:02:22 GMT X-Originating-IP: [24.112.20.116] X-Originating-Email: [thedumbkid@hotmail.com] From: "Danny Su" To: pgsql-sql@postgresql.org Subject: generic return for functions Date: Sun, 01 Jun 2003 00:02:22 -0400 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 01 Jun 2003 04:02:22.0642 (UTC) FILETIME=[9AA29120:01C327F2] X-Virus-Scanned: by amavisd-new X-Archive-Number: 200306/1 X-Sequence-Number: 13759 Hi, this is my first time using mailing list. Someone over at tek-tips suggested that I try here to see if someone can help me. I am currently converting everything from SQL Server to PostgreSQL. This is for an application that is going to support Oracle, SQL Server and PostgreSQL at the same time. I have done a lot of the conversion already but I am stuck on functions that returns parts of views or tables. In SQL Server, you can create User Defined functions that returns type "TABLE"... so then you can simply return the result of a select statement... (e.g. return select * from mytable) The problem is that I don't know if there is a way to do this in PostgreSQL. My functions and stored procedures in SQL Server involves select statement that gets columns from few views and tables. I know I can create my own data type with all the columns that are going to be returned, or get my function to return a type "record"... however, I don't like both of these methods since some of my functions involves returning a select statement using inner join and all that stuff... some have like 30 columns There seems to be another way to use refcursor but my application is in ColdFusion... refcursor doesn't seem to work with it. I know "returns setof record" and "returns setof my_own_datatype" work, but I would like to know if there is a better way? Something that's like "returns setof record" but without having to define all the columns when I call the function? {i.e. without the need to do: select * from myfunction() as (column1 type1, column2...);} If there is such method? It will allow me to maintain the application much easier and makes the conversion task much easier :) Thanks. /Danny _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail