X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9CE735280B for ; Wed, 1 Jun 2005 01:59:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81344-09 for ; Wed, 1 Jun 2005 04:59:49 +0000 (GMT) Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) by svr1.postgresql.org (Postfix) with ESMTP id 7DC005282A for ; Wed, 1 Jun 2005 01:59:46 -0300 (ADT) Received: from ausbayes1.aus.pervasive.com ([172.16.8.6]) by ausimss.pervasive.com with InterScan Messaging Security Suite; Tue, 31 May 2005 23:59:41 -0500 Received: from BLRMAIL1.aus.pervasive.com ([10.3.16.60]) by ausbayes1.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 31 May 2005 23:59:33 -0500 content-class: urn:content-classes:message Subject: Re: Multiple SRF parameters from query MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Wed, 1 Jun 2005 10:29:29 +0530 Message-ID: <02767D4600E59A4487233B23AEF5C59922C2B7@blrmail1.aus.pervasive.com> X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Multiple SRF parameters from query Thread-Index: AcVl8UFtzHmm8Z7OQgS+uRPBsBCGMwAdiW7Q From: "Ramakrishnan Muralidharan" To: "Federico Pedemonte" , X-OriginalArrivalTime: 01 Jun 2005 04:59:36.0318 (UTC) FILETIME=[B53B31E0:01C56666] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.055 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/71 X-Sequence-Number: 21672 Hi, I am not able to understand "Returning only one row", since 'aaa' = having 2 rows and 'bbb' having 3 rows and what criteria single row = should be returned. Please let me know the expected result and I will = try to find out a solution for it. for set returning function the following link maybe helpful=20 http://techdocs.postgresql.org/guides/SetReturningFunctions Regards, R.Muralidharan -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Federico Pedemonte Sent: Tuesday, May 31, 2005 8:23 PM To: pgsql-sql@postgresql.org Subject: [SQL] Multiple SRF parameters from query Hi All, i'm having troubles trying to write a sql query using a Set Returning Function. I have a function foo (ID varchar) that returns a variable number of records. I have also a table (called Anagrafica) that contains a list of IDs to be passed to the function foo. As an example, just say that Anagrafica is like this: Anagrafica ID | n ----+--- aaa | 1 bbb | 5 ccc | 9 ddd | 10 eee | 11 and foo returns this values=20 select * from foo ('aaa') a | b | c --+---+--- 1 | 2 | 3 5 | 9 | 1 select * from foo ('bbb') a | b | c --+---+--- 4 | 0 | 0=20 2 | 0 | 0 0 | 0 | 0=20 what i would like to do is write an SQL query that looks something like this (written in simplyfied-pseudo-sql) SELECT FROM anagrafica WHERE n < 5=20 SELECT * FROM Foo (anagrafica.ID)=09 =20 and that gives as result a table that is the union of foo ('aaa') and foo ('bbb') a | b | c --+---+--- 1 | 2 | 3 5 | 9 | 1 4 | 0 | 0=20 2 | 0 | 0 0 | 0 | 0=20 I'm having success if foo returns only a row, but the problem is that foo returns more than one. I think i sould use a join but i couldn't find the right syntax for it. I don't want to create a spefic PL/pgSQL function becase i need to have freedom in selecting IDs from Anagrafica (the one i provided is just an example, the real table is much more complex). I would really appreciate any suggestion. Best regards,=20 Federico. ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org