Re: Some additional PostgreSQL questions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marc SCHAEFER <alphanet-postgresql-sql(at)alphanet(dot)ch>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Some additional PostgreSQL questions
Date: 2002-05-27 20:06:10
Message-ID: 26961.1022529970@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Marc SCHAEFER <alphanet-postgresql-sql(at)alphanet(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-05-27 20:06:53 Re: Trees in SQL
Previous Message Christopher Kings-Lynne 2002-05-27 18:24:31 Re: Trees in SQL