From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vlad Dimitriu <vlad.dimitriu@base.ro>
Cc: pgsql-sql@postgresql.org
Subject: Re: Exception handling from trigger
Date: Mon, 09 Aug 2004 13:14:03 -0400
Message-ID: <16661.1092071643@sss.pgh.pa.us> (raw)
In-Reply-To: <4117AA90.9080704@base.ro>
References: <4117AA90.9080704@base.ro>
Vlad Dimitriu <vlad.dimitriu@base.ro> writes:
> I would like to handle the exceptions that a database returns. For example,
> if a "mycolumn" column is defined as varchar(64), I'd like to catch
> if the new.mycolumn is larger than 64 with my own trigger
You can't. From a logical perspective this is sensible, because the
trigger is handed data already formed into a tuple. If the presented
tuple contained a mycolumn value wider than 64 characters then it would
not be a legal value of the rowtype (any more than if, say, the column
value were an integer and not a varchar at all).
What I'd suggest if you want this is to remove the datatype restriction
and instead rely on your trigger to enforce the limitation.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, vlad.dimitriu@base.ro
Subject: Re: Exception handling from trigger
In-Reply-To: <16661.1092071643@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox