Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA90443 for ; Wed, 19 Jan 2000 10:42:07 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id KAA09887; Wed, 19 Jan 2000 10:41:43 -0500 (EST) To: Jose Soares cc: Marc Tardif , pgsql-sql@postgreSQL.org Subject: Re: [SQL] char(19) to varchar(32) In-reply-to: <3885C3C0.2B26A120@sferacarta.com> References: <3885C3C0.2B26A120@sferacarta.com> Comments: In-reply-to Jose Soares message dated "Wed, 19 Jan 2000 15:01:37 +0100" Date: Wed, 19 Jan 2000 10:41:43 -0500 Message-ID: <9884.948296503@sss.pgh.pa.us> From: Tom Lane Jose Soares 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