Re: value too long for type character varying(25)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Frank Yip <frankyip(at)nasitron(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: value too long for type character varying(25)
Date: 2002-11-19 14:11:05
Message-ID: 20374.1037715065@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Frank Yip <frankyip(at)nasitron(dot)com> writes:
> which say "Prior to PostgreSQL 7.2, strings that were too long were
> silently truncated, no error was raised."
> does anyone know if there is a option to set it truncate the strings?

No. But in 7.3 you can do something like

insert into foo values('your data here'::varchar(25));

An explicit coercion to varchar(n) will truncate the data without error.
An implicit coercion will raise an error. Yes, it's pretty bizarre,
but it's what the SQL spec says to do when you read it closely enough.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Oliver Elphick 2002-11-19 14:49:32 Re: [SQL] Problems invoking psql. Help please.
Previous Message Rod Kreisler 2002-11-19 13:27:29 Re: Why am I getting this message sometimes?