Обсуждение: How to NOT perform an insert

Поиск
Список
Период
Сортировка

How to NOT perform an insert

От
"Fontenot, Paul"
Дата:
Can I prevent an insert based on what is in a particular field?

For example, I use PostgreSQL as the backend for my syslog servers and
would like to log when some one makes a configuration change but not
when an ICMP echo request has been denied by the os. I think a function
/ trigger combination can do this but I'm not sure.

 ***PRIVILEGED & CONFIDENTIAL***
Unless expressly stated otherwise, this message (and any attachment(s)
thereto) is confidential and may be privileged. It is intended for the
addressee(s) only. If you are not an addressee, any disclosure or
copying of the contents of this e-mail or any action taken (or not
taken) in reliance on it is strictly prohibited. If you are not an
addressee, please inform sender immediately and delete this message from
your system.

Re: How to NOT perform an insert

От
Tom Lane
Дата:
"Fontenot, Paul" <Paul.Fontenot@bannerhealth.com> writes:
> Can I prevent an insert based on what is in a particular field?

Yeah, a BEFORE INSERT trigger can cause the insertion to be skipped
--- just return NULL, instead of returning the row to insert as you'd
normally do.

            regards, tom lane