Re: [SQL] char(19) to varchar(32)
| От | Tom Lane |
|---|---|
| Тема | Re: [SQL] char(19) to varchar(32) |
| Дата | |
| Msg-id | 9884.948296503@sss.pgh.pa.us обсуждение |
| Ответ на | Re: [SQL] char(19) to varchar(32) (Jose Soares <jose@sferacarta.com>) |
| Ответы |
Re: [SQL] char(19) to varchar(32)
|
| Список | pgsql-sql |
Jose Soares <jose@sferacarta.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
В списке pgsql-sql по дате отправления: