dbTalk Databases Forums  

Field with character varying (255)

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Field with character varying (255) in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Christopher A. Goodfellow
 
Posts: n/a

Default Field with character varying (255) - 04-26-2004 , 11:48 AM






I have a table with a field set to character varying (255). When an insert
is executed with a value for this field greater than 255 characters, an
error is generated rather than the input being truncated as stated in the
postgresql docs.

Postgresql version 7.3.2.

This problem did not occur in postgresql version 6.5 and the values were
truncated.


Output from \d of the filed in question below....

Column | Type | Modifiers
---------------+------------------------+-----------------------------------
------------------------
questions | character varying(255) |


Thank You,
Christopher A. Goodfellow
Director of Information Technology
Tealuxe, Inc.
Phone: 508 520 7887 ex:22
Fax: 508 528 8999
www.tealuxe.com
tea for all



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #2  
Old   
CoL
 
Posts: n/a

Default Re: Field with character varying (255) - 04-27-2004 , 08:40 AM






hi,

Christopher A. Goodfellow wrote:

Quote:
I have a table with a field set to character varying (255). When an insert
is executed with a value for this field greater than 255 characters, an
error is generated rather than the input being truncated as stated in the
postgresql docs.

Postgresql version 7.3.2.

This problem did not occur in postgresql version 6.5 and the values were
truncated.
this changed, see the documantation for more info. Do not insert longer
value, or use trigger to truncate the value, before insert.

C.


Reply With Quote
  #3  
Old   
Bruno Wolff III
 
Posts: n/a

Default Re: Field with character varying (255) - 04-27-2004 , 12:38 PM



On Mon, Apr 26, 2004 at 12:48:43 -0400,
"Christopher A. Goodfellow" <cgoodfellow (AT) tealuxe (DOT) com> wrote:
Quote:
I have a table with a field set to character varying (255). When an insert
is executed with a value for this field greater than 255 characters, an
error is generated rather than the input being truncated as stated in the
postgresql docs.
Are you using an explicit cast? An implicit cast will return an error,
but an explicit cast should silently truncate the string.
This example is in a 7.4.2+ database:
bruno=> create table test3 (col varchar(3));
CREATE TABLE
bruno=> insert into test3 values ('1234');
ERROR: value too long for type character varying(3)
bruno=> insert into test3 values ('1234'::varchar(3));
INSERT 1242541 1
bruno=> select * from test3;
col
-----
123
(1 row)

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.