pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ivan Sergio Borgonovo <mail@webthatworks.it>
To: pgsql-sql@postgresql.org
Subject: Re: plpgsql vs. SQL in stored procedures
Date: Wed, 31 Mar 2004 13:07:56 +0200
Message-ID: <20040331130756.2cc03a1e@stige.webthatworks.it> (raw)
In-Reply-To: <m3r7v9zad6.fsf@wolfe.cbbrowne.com>
References: <20040331000808.7aaedc33@stige.webthatworks.it>
	<m3r7v9zad6.fsf@wolfe.cbbrowne.com>

On Wed, 31 Mar 2004 03:31:01 -0500
Christopher Browne <cbbrowne@acm.org> 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 lapse<dateadd(mi,-25,getdate())
    declare @R_ID int

    set @R_ID=(select R_ID from auth where
        lapse>dateadd(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.




view thread (4+ messages)  latest in thread

Message-ID: <20040331130756.2cc03a1e@stige.webthatworks.it>
Permalink:  ../20040331130756.2cc03a1e@stige.webthatworks.it/
Also on:    postgresql.org/message-id/20040331130756.2cc03a1e@stige.webthatworks.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mail@webthatworks.it
  Subject: Re: plpgsql vs. SQL in stored procedures
  In-Reply-To: <20040331130756.2cc03a1e@stige.webthatworks.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox