X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 14692D1B4A7 for ; Fri, 16 Jan 2004 11:31:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19441-03 for ; Fri, 16 Jan 2004 07:31:03 -0400 (AST) Received: from poweredge.attiksystem.ch (unknown [212.147.59.29]) by svr1.postgresql.org (Postfix) with ESMTP id 1E620D1B456 for ; Fri, 16 Jan 2004 07:30:59 -0400 (AST) content-class: urn:content-classes:message Subject: sql query with join and parameter in postgresql function MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Fri, 16 Jan 2004 12:30:56 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Message-ID: <6C0CF58A187DA5479245E0830AF84F4208018E@poweredge.attiksystem.ch> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: sql query with join and parameter in postgresql function Thread-Index: AcPcJII/564BXaxpQvuJnqD9gnUnYw== From: "Philippe Lang" To: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/137 X-Sequence-Number: 16530 Hello, I'd like to write a function similar to that: ------------------------------------------------ CREATE FUNCTION public.report_join_parameter(char(6)) RETURNS ??? AS ' SELECT tableA.field1, tableA.field2, tableB.field1, tableB.field2, tableC.field1, tableC.field2, FROM tableA INNER JOIN tableB ON tableA.pk =3D tableB.fk INNER JOIN tableC ON tableB.pk =3D tableC.fk WHERE tableC.field3=3D 0 AND tableB.field1=3D $1 ' LANGUAGE 'sql' VOLATILE; ------------------------------------------------ Do I ***HAVE TO*** define a composite type for the columns my function is supposed to return? Isn't there a simpler method, that could allow me to avoid this extra work? I thought a view would be more appropriate, but if I'm not wrong, a view does not accept any parameter as input... Thanks! Philippe