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 141649260E2 for ; Sun, 1 Jun 2003 01:10:02 -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 28874-03 for ; Sun, 1 Jun 2003 01:09:51 -0400 (EDT) Received: from cfftechnologies.com (dsl081-147-127.chi1.dsl.speakeasy.net [64.81.147.127]) by developer.postgresql.org (Postfix) with ESMTP id 3379C9260DC for ; Sun, 1 Jun 2003 01:09:51 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by cfftechnologies.com (Postfix on SuSE Linux 8.0 (i386)) with ESMTP id 2778C20C09B for ; Sun, 1 Jun 2003 00:05:40 -0500 (CDT) Received: from cfftechnologies.com ([127.0.0.1]) by localhost (coral [127.0.0.1]) (amavisd-new) with ESMTP id 09875-10 for ; Sun, 1 Jun 2003 00:05:39 -0000 (CDT) Received: from CFFtechnologies.com (dhcp109.cfftechnologies.world [192.168.129.109]) by cfftechnologies.com (Postfix on SuSE Linux 8.0 (i386)) with ESMTP id 5170E20C09A for ; Sun, 1 Jun 2003 00:05:39 -0500 (CDT) Date: Sun, 1 Jun 2003 00:09:54 -0500 Subject: Re: generic return for functions Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Avi Schwartz To: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <47F83F6F-93EF-11D7-ACB0-000393AE5044@CFFtechnologies.com> X-Mailer: Apple Mail (2.552) X-Virus-Scanned: by amavisd-new amavisd-new-20020630 X-Razor-id: db1e948f8901af9507a23528046174294825aa90 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200306/2 X-Sequence-Number: 13760 I am afraid you are in exactly the same boat I am in. Coldfusion does not recognize the refcursor and as far as I know, currently the only way to return a result set that CF can read is to return a setof which requires you to return a user defined data type or a record. Another thing that causes me some minor grief is the fact that currently you cannot have default values to function parameters, a feature we use a lot. Avi On Saturday, May 31, 2003, at 23:02 America/Chicago, Danny Su wrote: > 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 :) -- Avi Schwartz avi@CFFtechnologies.com