Re: [SQL] char(19) to varchar(32)
От | Jose Soares |
---|---|
Тема | Re: [SQL] char(19) to varchar(32) |
Дата | |
Msg-id | 3885C3C0.2B26A120@sferacarta.com обсуждение исходный текст |
Ответ на | char(19) to varchar(32) (Marc Tardif <admin@wtbwts.com>) |
Ответы |
Re: [SQL] char(19) to varchar(32)
|
Список | 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 по дате отправления: