Skip site navigation (1) Skip section navigation (2)

Re: [SQL] PL/pgSQL examples NOT involving functions

From: "Aasmund Midttun Godal" <postgresql(at)envisity(dot)com>
To: roland(at)astrofoto(dot)org
Cc: pgsql-docs(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] PL/pgSQL examples NOT involving functions
Date: 2001-11-15 21:50:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-docspgsql-sql
Well, to the best of my knowledge your question is a contradiction in terms:

plpgsql is a procedural language to use it you must create a stored procedure or function...

However you are probably able to do many of the things you may want with plain old SQL look it up in the docs especially the case structure.


On 15 Nov 2001 11:49:12 -0500, Roland Roberts <roland(at)astrofoto(dot)org> wrote:
> How can I write a few lines of PL/pgSQL which do not involve creating
> a function?  I can find no examples of this in the docs, but say I
> would like to do something like
>     BEGIN
>     IF EXISTS (SELECT * FROM foo WHERE idx = 27)
>     THEN
>         UPDATE foo SET var='some value' WHERE idx=27;
>     ELSE
>         INSERT INTO foo (idx, var) VALUES (27, 'some value');
>     END IF
>     END;
> roland
> -- 
> 		       PGP Key ID: 66 BC 3B CD
> Roland B. Roberts, PhD                             RL Enterprises
> roland(at)rlenter(dot)com                     76-15 113th Street, Apt 3B
> roland(at)astrofoto(dot)org                       Forest Hills, NY 11375
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Aasmund Midttun Godal

aasmund(at)godal(dot)com -
+47 40 45 20 46

In response to


pgsql-docs by date

Next:From: Tom LaneDate: 2001-11-15 23:07:28
Subject: Cross-posting (was Re: PL/pgSQL examples NOT involving functions)
Previous:From: Roland RobertsDate: 2001-11-15 21:21:33
Subject: Re: PL/pgSQL examples NOT involving functions

pgsql-sql by date

Next:From: Ross J. ReedstromDate: 2001-11-15 22:03:38
Subject: Re: INSERT question
Previous:From: Jason EarlDate: 2001-11-15 21:28:26
Subject: Re: INSERT question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group