Skip site navigation (1) Skip section navigation (2)

Re: [SQL] char(19) to varchar(32)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jose Soares <jose(at)sferacarta(dot)com>
Cc: Marc Tardif <admin(at)wtbwts(dot)com>, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] char(19) to varchar(32)
Date: 2000-01-19 15:41:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Jose Soares <jose(at)sferacarta(dot)com> writes:
> You have to cast the varchar field as char. Example:  CAST (company AS CHAR)

> For example:

>    company varchar(32)
> );
> insert into test values('12345678901234567890123456789012');
> CREATE TABLE test1 (
>    company char(19)
> );
> insert into test1 (company) select cast( as char);

Actually, you should get the same results with or without a cast,
because the system implicitly inserts a cast to char(19) before storing
data into

Or at least it's supposed to.  There have been bugs in that area in
past versions.  Jose's example works as I expect --- same result
with or without cast --- but I wonder whether Marc has found a problem
in pl/pgsql's handling of this situation.  Marc, you didn't actually
say why you thought that

>> company is char(19);
>> is varchar(32);

didn't work; what behavior are you seeing?

			regards, tom lane

In response to


pgsql-sql by date

Next:From: Sevo StilleDate: 2000-01-19 16:32:23
Subject: (no subject)
Previous:From: Marc TardifDate: 2000-01-19 15:40:45
Subject: Re: [SQL] Foreign Keys, Triggers and such

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group