Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 6DAA49FB2C3 for ; Thu, 18 Jan 2007 09:47:32 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 88894-07 for ; Thu, 18 Jan 2007 09:47:28 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from a2s5.a2hosting.com (a2s5.a2hosting.com [209.124.50.10]) by postgresql.org (Postfix) with ESMTP id 1C4B09FA2FC for ; Thu, 18 Jan 2007 09:47:28 -0400 (AST) Received: from adsl-150-239-12.tys.bellsouth.net ([72.150.239.12] helo=[192.168.1.12]) by a2s5.a2hosting.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1H7Xby-0004NL-3v; Thu, 18 Jan 2007 08:47:26 -0500 In-Reply-To: <62559.82.143.192.130.1169105936.squirrel@mail.agile.dk> References: <1364.62.66.218.59.1169073199.squirrel@mail.agile.dk> <2AFADCD2-C72D-40FB-8B8E-D6FD023F2148@pgedit.com> <62559.82.143.192.130.1169105936.squirrel@mail.agile.dk> Mime-Version: 1.0 (Apple Message framework v752.3) X-Priority: 3 (Normal) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <603CB0E8-EFBD-4762-BC45-AFAD248E484B@pgedit.com> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: John DeSoi Subject: Re: Some help with functions-syntax Date: Thu, 18 Jan 2007 08:47:19 -0500 To: Jan Meyland Andersen X-Mailer: Apple Mail (2.752.3) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s5.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/75 X-Sequence-Number: 27227 On Jan 18, 2007, at 2:38 AM, Jan Meyland Andersen wrote: > But the problem here is that the where-clause depends on the > relkind. That > is why I'm trying to solve the problem this way. I think that clause can be written as a subselect and added to the expression. Or just make that a separate function and AND the function call with your query expression. > > How do I then write EXECUTE queries on multiple lines, if I go with > this > solution? You can make it a big multi-line string. Or you can build the string, something like: declare _sql begin _sql := _sql + 'select ...' _sql := _sql + ' where ...' But using the form without execute is much better. PostgreSQL will only have to plan the query the first time it is called. Using EXECUTE is much less efficient. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL