From: | Roland Roberts <roland(at)astrofoto(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org, pgsql-docs(at)postgresql(dot)org |
Subject: | PL/pgSQL examples NOT involving functions |
Date: | 2001-11-15 16:49:12 |
Message-ID: | m2adxoget3.fsf@tycho.rlent.pnet |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2001-11-15 20:54:32 | Re: PL/pgSQL examples NOT involving functions |
Previous Message | Bruce Momjian | 2001-11-15 16:39:16 | Re: [DOCS] Use of 'now' |
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2001-11-15 16:52:05 | Re: handling exceptions, really not simple... :-(( |
Previous Message | Roland Roberts | 2001-11-15 16:44:44 | Re: Help with INSERT into 2 tables |