Error size varchar

Started by Edwin Quijadaover 22 years ago5 messagesgeneral
Jump to latest
#1Edwin Quijada
listas_quijada@hotmail.com

Hi!!
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.
This error is over than trigger execution??

This is the error

ERROR: value too long for type character varying(30)

*-------------------------------------------------------*
*-Edwin Quijada
*-Developer DataBase
*-JQ Microsistemas
*-809-747-2787
* " Si deseas lograr cosas excepcionales debes de hacer cosas fuera de lo
comun"
*-------------------------------------------------------*

_________________________________________________________________
Surf and talk on the phone at the same time with broadband Internet access.
Get high-speed for as low as $29.95/month (depending on the local service
providers in your area). https://broadband.msn.com

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Edwin Quijada (#1)
Re: Error size varchar

"Edwin Quijada" <listas_quijada@hotmail.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

#3Edwin Quijada
listas_quijada@hotmail.com
In reply to: Tom Lane (#2)
Re: Error size varchar

wHAT IS unconstrained varchar???

*-------------------------------------------------------*
*-Edwin Quijada
*-Developer DataBase
*-JQ Microsistemas
*-809-747-2787
* " Si deseas lograr cosas excepcionales debes de hacer cosas fuera de lo
comun"
*-------------------------------------------------------*

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Edwin Quijada" <listas_quijada@hotmail.com>
CC: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Error size varchar Date: Wed, 29 Oct 2003 11:28:23
-0500

"Edwin Quijada" <listas_quijada@hotmail.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

_________________________________________________________________
Fretting that your Hotmail account may expire because you forgot to sign in
enough? Get Hotmail Extra Storage today!
http://join.msn.com/?PAGE=features/es

#4Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Edwin Quijada (#3)
Re: Error size varchar

On Wed, Oct 29, 2003 at 05:06:50PM +0000, Edwin Quijada wrote:

wHAT IS unconstrained varchar???

VARCHAR with no "(n)" or just TEXT, which is the same thing.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
La web junta la gente porque no importa que clase de mutante sexual seas,
tienes millones de posibles parejas. Pon "buscar gente que tengan sexo con
ciervos incendi�nse", y el computador dir� "especifique el tipo de ciervo"
(Jason Alexander)

#5Adam Kavan
akavan@cox.net
In reply to: Edwin Quijada (#3)
Re: Error size varchar

At 05:06 PM 10/29/03 +0000, Edwin Quijada wrote:

wHAT IS unconstrained varchar???

Define the column as just varchar. This allows a string of any
length. Then have a trigger truncate it after it is inserted.

--- Adam Kavan
--- akavan@cox.net