Marc SCHAEFER <alphanet-postgresql-sql@alphanet.ch> writes:
> compta=> DELETE FROM ecriture WHERE id = 1;
> DELETE 0
> The funny thing is the DELETE not saying an error, but not deleting (which
> is good, but I would like an error).
Then make your trigger raise an error. Returning NULL out of the
trigger means "silently suppress this operation". There's not much
point in having the system report an error; it has no idea what the
error condition is, while the trigger presumably knows why it's unhappy
and so can give a useful error message.
> How can I defer the trigger call til the end of the transaction ?
AFAIK we don't currently have end-of-transaction triggers, only
end-of-statement triggers.
> EXECUTE ''INSERT INTO ecriture(libelle)''
> || '' SELECT ''
> || quote_ident($2 || ''.libelle'')
> || '' FROM ''
> || quote_ident($2)
> || '' ORDER BY ''
> || quote_ident($2 || ''.id'');
I think you want quote_ident($2) || ''.libelle'' and so forth.
What you'll get from that is "tablename.libelle", what you want
is "tablename".libelle, no?
regards, tom lane