Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id B2CAF6330A6 for ; Mon, 6 Apr 2009 13:42:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 73387-04 for ; Mon, 6 Apr 2009 13:42:29 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.30]) by mail.postgresql.org (Postfix) with ESMTP id AE094633059 for ; Mon, 6 Apr 2009 13:42:29 -0300 (ADT) Received: by yx-out-2324.google.com with SMTP id 8so1502061yxm.73 for ; Mon, 06 Apr 2009 09:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=EYYQwjIhr55XCFFiIbf26fYK1Lo4mpyhSbwcjKwJgmA=; b=CPL3/YWqwZg/8fmR4c3pDWDQPZx5iHHZLwa/Lci39xPWRSzcBXqjIfP+S7/xMSGou9 gR7Rcs6mi+Mwk2eHrP7kfvxxWOdIFYxuh/s/aBs2ZZB1MBLSFqG9jF5+JOEnQc74PugX Q4GUvk7QTBOOh+omsbTCZj2HZVCaM/+qeclqk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=ckG9KcjMgkpvU6iZkxHMXKUujJeAHOkLe9IhqAMssSQTeRAiJe0xhsSxOUA5dXkdyO 7gRntJR35D1gfrRpkLQcKFtjibmAGi7hyLlmBzHPdirq8ke7931z6kI/ARqSVXqhlGQq BKIsrDMeEABJbf0nGC4OCfY1lvOC5tlptluoo= MIME-Version: 1.0 Received: by 10.151.103.11 with SMTP id f11mr8717888ybm.189.1239036149048; Mon, 06 Apr 2009 09:42:29 -0700 (PDT) In-Reply-To: <29505E7D-05C7-4F8A-91AD-C5596FA51987@pgedit.com> References: <4544e0330904031403i218fdb3cxf18d8971ff284290@mail.gmail.com> <29505E7D-05C7-4F8A-91AD-C5596FA51987@pgedit.com> Date: Mon, 6 Apr 2009 11:42:29 -0500 Message-ID: <4544e0330904060942x379fac35n63b1ebf6d661f26a@mail.gmail.com> Subject: Re: pl/pgsql or control structures outside of a function? From: Peter Koczan To: John DeSoi Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/41 X-Sequence-Number: 32387 On Fri, Apr 3, 2009 at 11:28 PM, John DeSoi wrote: >> Is there any way to use PL/pgSQL code outside of a function? > > No. I kinda figured, but it doesn't hurt to ask. >> The reason I'm asking is that I'm porting some code from >> sybase/isql/SQR, and it allows some control code structures to be used >> in an sql script. For instance, > > CASE might work for you. > > http://www.postgresql.org/docs/8.3/interactive/functions-conditional.html Thanks for the suggestion. I think that for what I'm trying to do, adding a bunch of case statements would very quickly become unmaintainable. Wrapper scripts are probably the way to go for me. Thanks again, Peter