Dienstag, 27. Februar 2024

PL/pgSQL function trigger does not insert/update/delete records even though it is inteded and ought to

Lately, I developed an insert trigger that was supposed to check whether for specific cases a column of the new was filled or not and raise an exception if appropriate. However, it did not. It turns out that PL/pgSQL functions need to return a record, if one wants the original operation to happen. If NULL is returned, the operation is not carried out. Coming from Oracle, I missed it, even though it is quite clearly documented.

In hhe PostgreSQL way, it is easy to write a trigger that just does nothing if necessary. I would not know by heart how to do that in Oracle.

Keine Kommentare:

Kommentar veröffentlichen