Subject | Re: Help with a trigger/procedure |
---|---|
Author | Adam |
Post date | 2006-09-11T23:02:04Z |
--- In firebird-support@yahoogroups.com, "Fabio Gomes" <fabioxgn@...>
wrote:
select Coalesce(sum(qtde), 0) from table into :something;
delete from table;
insert into table (qtde) values (:something);
To get the count, other transactions must run:
select Coalesce(sum(qtde), 0) from table
If the procedure has just run, it will only be summing a handful of
records. There is a trade-off at play. The more frequent you execute
the procedure, the less records to sum (so it runs faster). The
procedure does require resources to run, so you don't want to run it
unnecessarily.
Adam
wrote:
>Pretty close, sum returns null if no records exist (not sure why either).
> Nice,
>
> So what my procedure will look like?
>
select Coalesce(sum(qtde), 0) from table into :something;
delete from table;
insert into table (qtde) values (:something);
> Will just it work?Yes.
To get the count, other transactions must run:
select Coalesce(sum(qtde), 0) from table
If the procedure has just run, it will only be summing a handful of
records. There is a trade-off at play. The more frequent you execute
the procedure, the less records to sum (so it runs faster). The
procedure does require resources to run, so you don't want to run it
unnecessarily.
Adam