From: | will trillich <will(at)serensoft(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | if exists, select; if not, create then select... ?? |
Date: | 2001-05-15 06:46:32 |
Message-ID: | 20010515014632.A18580@serensoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
okay. i seem to recall some discussion on pl/pgsql wherein a
function called via SELECT can't do an INSERT.
is there a way to do something like
select get_or_create(...);
which runs some pl/pgsql such as
select * from tbl where...;
if not found
insert into tbl values (...);
select * from tbl where...;
end if;
return found stuff, even if we had to create it...
or not?
i'm looking for results similar to perl code like
$something ||= &make_new();
# which translates to (more or less, for this application)
if ( ! defined( $something ) ) {
$something = &make_new();
}
return $something;
i've tried conceiving of a rule that might intervene properly,
but i'm stymied...
--
What do I need manners for? I already got me a wife.
-- Adam Pontipee, "Seven Brides for Seven Brothers"
will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!
From | Date | Subject | |
---|---|---|---|
Next Message | Diana Cionoiu | 2001-05-15 06:57:39 | Re: trailing spaces |
Previous Message | Justin Clift | 2001-05-15 04:30:22 | Re: PostgreSQL in Comparison to mySQL |