pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPlpgsql Language Feature?
2+ messages / 2 participants
[nested] [flat]
* Plpgsql Language Feature?
@ 1999-02-11 22:29 David Hartwig <daveh@insightdist.com>
1999-02-12 01:08 ` Re: [SQL] Plpgsql Language Feature? Jan Wieck <jwieck@debis.com>
0 siblings, 1 reply; 2+ messages in thread
From: David Hartwig @ 1999-02-11 22:29 UTC (permalink / raw)
To: pgsql-sql
In the context of a plpgsql script is a possible to access the number of
rows effected by an UPDATE or DELETE statement? It could be used to
simplify, and probably improve performance on, many scripts. I would
like to do something like:
update foo set bar = bar + new.amount where key = new.key;
if ROWS_UPDATED > 0 then
-- This would be less likely to occur
insert into foo (key, bar) values (new.key, new.bar);
end if;
Otherwise I must construct an additional SELECTstatement to see if the
row exists. Something like:
select 1 from foo where key = new.key;
if found then
update foo set bar = bar + new.amount where key = new.key;
else
insert into foo (key, bar) values (new.key, new.bar);
end if;
Might this be a worth while feature if it does not now exist?
TIA.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] Plpgsql Language Feature?
1999-02-11 22:29 Plpgsql Language Feature? David Hartwig <daveh@insightdist.com>
@ 1999-02-12 01:08 ` Jan Wieck <jwieck@debis.com>
0 siblings, 0 replies; 2+ messages in thread
From: jwieck@debis.com @ 1999-02-12 01:08 UTC (permalink / raw)
To: daveh@insightdist.com; +Cc: pgsql-sql
> In the context of a plpgsql script is a possible to access the number of
> rows effected by an UPDATE or DELETE statement? It could be used to
> simplify, and probably improve performance on, many scripts. I would
> like to do something like:
>
> update foo set bar = bar + new.amount where key = new.key;
>
> if ROWS_UPDATED > 0 then
> -- This would be less likely to occur
> insert into foo (key, bar) values (new.key, new.bar);
> end if;
Yes, I think this would be a nice feature. Will take a look
if I can add it before v6.5 BETA starts.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-02-12 01:08 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-02-11 22:29 Plpgsql Language Feature? David Hartwig <daveh@insightdist.com>
1999-02-12 01:08 ` Jan Wieck <jwieck@debis.com>
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