Re: char vs. varchar
Posted in 2000
Red Valsen wrote: > > My Java developers have been struggling mightily against character type > columns. They have been carping about the need to trim, in one way or > another, trailing blanks from all manner of values they pull from > tables. Why can't all those nasty fixed length columns be > varchar(255)? Arguments of higher overhead and storage requirements > didn't satisfy. > > Why shouldn't all those chars be varchars? And exactly what are the > higher overhead and storage requirements? Varchar is not the problem. The problem is the host variable type. Informix supports four different host character variable types all of which behave differently. The effects are described in the ESQL/C manual: ESQL/C-TYPE Behavior w/CHAR cols Behavior w/VARCHAR cols ----------- -------------------------- ----------------------- char space pad and NULL term. space pad to MAX & NULL terminate varchar space pad and NULL term. space pad to current length (including slack) and NULL terminate fixchar space pad, no termination space pad to MAX, no termination (hard spaces not stripped) string strip trailing spaces, NULL strip trailing spaces terminate (including hard spaces) and NULL terminate I do not know how you get these other host types for Java but it must be in the FM. Art S. Kagel