Subject Re: [firebird-support] What programming languages and toolkits do you use to access Firebird?
Author Milan Babuskov
Mercea Paul wrote:
> CREATE OR ALTER TRIGGER mytable_COUNTROWS FOR mytable
> ACTIVE AFTER INSERT POSITION 0
> AS
> begin
> if (not exists(select 1 from tablesrows t where t.table_name='mytable')
> then
> insert into tablesrows (table_name, table_rows) values ('mytable',1);
>
> update tablesrows set table_rows = (select count(id) from mytable);
> end

This looks more like a 'shot in the foot' to me. Something like:

if (inserting)
update tablesrows set table_rows = table_rows + 1;
if (deleting)
update tablesrows set table_rows = table_rows - 1;

would work much faster. However, you'd still get update conflicts
(deadlocks).

--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com