| 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: | 9884.948296503@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| 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:
> CREATE TABLE test (
>    company varchar(32)
> );
> insert into test values('12345678901234567890123456789012');
>
> CREATE TABLE test1 (
>    company char(19)
> );
> insert into test1 (company) select cast(test.company 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 test1.company.
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);
>> NEW.company is varchar(32);
didn't work; what behavior are you seeing?
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sevo Stille | 2000-01-19 16:32:23 | (no subject) | 
| Previous Message | Marc Tardif | 2000-01-19 15:40:45 | Re: [SQL] Foreign Keys, Triggers and such |