Re: Error size varchar

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Edwin Quijada" <listas_quijada(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Error size varchar
Date: 2003-10-29 16:28:23
Message-ID: 5244.1067444903@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Edwin Quijada" <listas_quijada(at)hotmail(dot)com> writes:
> I got error about a length field varchar. I have a table with a field type
> varchar(20) but if I try to set to this field more than 20 characters I got
> error.
> I did a function to control the length of data and put it on trigger but
> when it ocurrs I got the error anyway and the trigger not works.

The length constraint is checked before triggers are fired, I believe.
If you want silent truncation rather than an error, use a text column
(or unconstrained varchar) and put the truncation behavior into your
trigger.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lada 'Ray' Lostak 2003-10-29 16:42:30 Re: Performace question
Previous Message Tom Lane 2003-10-29 16:24:25 Re: 7.3.5 release (was: Re: SELECT with row>32k hangs over SSL-Connection)