Thread: Error size varchar
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
"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
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
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)
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