From: | Alex Pilosov <alex(at)pilosoft(dot)com> |
---|---|
To: | Warren Vanichuk <pyber(at)street-light(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: A question about PL/pgSQL |
Date: | 2000-10-28 04:00:22 |
Message-ID: | Pine.BSO.4.10.10010272359440.2291-100000@spider.pilosoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 27 Oct 2000, Warren Vanichuk wrote:
>
> Greetings.
>
> I am writting up a function in PL/pgSQL to automate a couple of multi-table
> updates, and I have a question.
>
> I need to check to see if the data is already in the database, and if it is,
> perform and update, or if it's not, perform an insert. The lookup is
> against a primary key, so I only have to worry about 1 or 0 rows being
> returned from the select statement.
>
> I attempted something like
>
> IF SELECT id FROM overview WHERE id = 100 ...
>
> but I get an 'error near SELECT' returned from the database.
declare foo record;
begin
select into foo * from overview...
if not found
insert...
else ...
end if;
end;
From | Date | Subject | |
---|---|---|---|
Next Message | Igor Roboul | 2000-10-28 04:02:47 | Re: timestamp? |
Previous Message | Tom Lane | 2000-10-28 03:52:52 | Re: newbie question: ERROR: getattproperties: no attribute tuple 1259 -2 |