Re: [SQL] char(19) to varchar(32) - Mailing list pgsql-sql

From Jose Soares
Subject Re: [SQL] char(19) to varchar(32)
Date
Msg-id 3885C3C0.2B26A120@sferacarta.com
Whole thread Raw
In response to char(19) to varchar(32)  (Marc Tardif <admin@wtbwts.com>)
Responses Re: [SQL] char(19) to varchar(32)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
<tt>You have to cast the varchar field as char. Example:  CAST (company AS CHAR)</tt><br
/><tt></tt> <tt></tt><p><tt>Forexample:</tt><tt></tt><p><tt>CREATE TABLE test (</tt><br /><tt>   company
varchar(32)</tt><br/><tt>);</tt><br /><tt>insert into test
values('12345678901234567890123456789012');</tt><tt></tt><p><tt>CREATETABLE test1 (</tt><br /><tt>   company
char(19)</tt><br/><tt>);</tt><br /><tt>insert into test1 (company) select cast(test.company as
char);</tt><tt></tt><p><tt>select* from test;</tt><br /><tt>                         company</tt><br
/><tt>--------------------------------</tt><br/><tt>12345678901234567890123456789012</tt><br /><tt>(1
row)</tt><tt></tt><p><tt>select* from test1;</tt><br /><tt>            company</tt><br
/><tt>-------------------</tt><br/><tt>1234567890123456789</tt><br /><tt>(1 row)</tt><br
/><tt></tt> <tt></tt><p><tt>José</tt><br/>  <p>Marc Tardif wrote: <blockquote type="CITE">I have created a rule to
updatea char(19) field from a varchar(32) field. <br />I don't mind if half the field is cut out, I just want to copy
thefirst <br />19 characters. Here's what I have <br />... update products set company=NEW.company; <p>company is
char(19);<br />NEW.company is varchar(32); <p>Any suggestions on making this work? <br />Marc
<p>************</blockquote>

pgsql-sql by date:

Previous
From: "Mark Alliban"
Date:
Subject: Bug in CEIL?
Next
From: Tom Lane
Date:
Subject: Re: [SQL] Bug in CEIL?