X-Original-To: pgsql-general@postgresql.org Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by postgresql.org (Postfix) with ESMTP id 7DE7C47580B for ; Thu, 13 Mar 2003 17:07:52 -0500 (EST) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.0.4) with ESMTP-TLS id 1663370; Thu, 13 Mar 2003 14:43:46 -0800 Message-ID: <3E7100AA.40308@joeconway.com> Date: Thu, 13 Mar 2003 14:05:30 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Petre Scheie Cc: pgsql-general@postgresql.org Subject: Re: PL/Java (was: stored procedures) References: <3E70FB3B.2050502@nextelpartners.com> In-Reply-To: <3E70FB3B.2050502@nextelpartners.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200303/678 X-Sequence-Number: 39170 Petre Scheie wrote: > My DBA and I looked at the link on using SQL for stored procedures > (thanks Neil!) and he raised a couple concerns: > > 1. In the example given, the query is directed at just one table; he > says he needs to join multiple tables, and have it return a set. Can PG > do this? Pretty much any valid SQL statement will work. E.g. CREATE TYPE ex1_tup AS (relname name, colname name); CREATE OR REPLACE FUNCTION ex1(text) returns setof ex1_tup AS ' SELECT c.relname, a.attname FROM pg_class c JOIN pg_attribute a ON a.attrelid = c.oid WHERE relname = $1 ' LANGUAGE 'sql'; regression=# SELECT * FROM ex1('pg_group'); relname | colname ----------+---------- pg_group | tableoid pg_group | cmax pg_group | xmax pg_group | cmin pg_group | xmin pg_group | ctid pg_group | groname pg_group | grosysid pg_group | grolist (9 rows) > 2. The docs say this ability to return a set is deprecated and may be > removed in a future release. Why is that? Has this functionality been > replaced by something else (better?) That is referring to the older style of returning a set in the target list. It would look like: SELECT ex1('pg_group'); But that style has semantic problems, and in any case never really did what you wanted (a single column could be returned, but a composite return type just gave you back numeric pointers) HTH, Joe