X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EFB39D1DE14 for ; Wed, 31 Mar 2004 11:07:48 +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 60376-06 for ; Wed, 31 Mar 2004 07:07:40 -0400 (AST) Received: from vsmtp2.tin.it (vsmtp2alice.tin.it [212.216.176.142]) by svr1.postgresql.org (Postfix) with ESMTP id B6160D1E86E for ; Wed, 31 Mar 2004 07:07:36 -0400 (AST) Received: from caronte.webthatworks.it (80.180.154.149) by vsmtp2.tin.it (7.0.027) id 40643F020010392C for pgsql-sql@postgresql.org; Wed, 31 Mar 2004 13:07:39 +0200 Received: from stige.webthatworks.it (stige.webthatworks.it [192.168.1.5]) by caronte.webthatworks.it (Postfix) with ESMTP id 539C12300C0 for ; Wed, 31 Mar 2004 13:07:37 +0200 (CEST) Received: from stige.webthatworks.it (localhost [127.0.0.1]) by stige.webthatworks.it (Postfix) with SMTP id 18B1F294068 for ; Wed, 31 Mar 2004 13:07:57 +0200 (CEST) Date: Wed, 31 Mar 2004 13:07:56 +0200 From: Ivan Sergio Borgonovo To: pgsql-sql@postgresql.org Subject: Re: plpgsql vs. SQL in stored procedures Message-Id: <20040331130756.2cc03a1e@stige.webthatworks.it> In-Reply-To: References: <20040331000808.7aaedc33@stige.webthatworks.it> Organization: WebThatWorks.it X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i686-suse-linux) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/270 X-Sequence-Number: 17369 On Wed, 31 Mar 2004 03:31:01 -0500 Christopher Browne wrote: > The forthcoming support for recursive queries using a WITH clause > might provide, after a fashion, a way to declare variables. I think I'll have to work with pg 7.3 Does this translate to: you won't be able to use variables? I was used to do stuff like this with MS SQL create proc sp_getuid @uid uniqueidentifier as delete from auth where lapsedateadd(mi,-10,getdate()) and A_ID=@uid) if (@R_ID is null) begin delete from auth where A_ID=@uid select null as R_ID end else begin update auth set lapse=getdate() where A_ID=@uid select @R_ID as R_ID end Does it mean that to have variables in SP I'll have to use plpgsql in spite of plain SQL? > As for IF, there is a functional equivalent to it in the form of the > SQL standard CASE statement. TY for the refreshing pointer. I was looking in the wrong place.