Обсуждение: Insert into

Поиск
Список
Период
Сортировка

Insert into

От
azwa@nc.com.my
Дата:
<br /><br /><font face="Times New Roman" size="2">Hi,</font><br /><br /><font face="Times New Roman" size="2">  i've
structuretable like below and want to load data from temp table into table below :</font><br /><br /><br /><font
face="TimesNew Roman" size="2">    dwnc=> \d cust_lo_dim</font><br /><font face="Times New Roman" size="2">         
               Table "biosadm.cust_lo_dim"</font><br /><font face="Times New Roman" size="2">  Column   |         Type
        |                 Modifiers</font><br /><font face="Times New Roman"
size="2">-----------+-----------------------+------------------------------------------</font><br/><font face="Times
NewRoman" size="2"> lo_key    | integer               | not null default nextval('clo_seq'::text)</font><br /><font
face="TimesNew Roman" size="2"> lo_no     | character varying(25) | not null</font><br /><font face="Times New Roman"
size="2"> lo_date  | date                  |</font><br /><font face="Times New Roman" size="2"> rcvdate   | date      
          |</font><br /><font face="Times New Roman" size="2"> lo_status | character varying(15) |</font><br /><font
face="TimesNew Roman" size="2">Indexes: cust_lo_dim_pkey primary key btree (lo_key)</font><br /><br /><br /><font
face="TimesNew Roman" size="2">my temp table as below:</font><br /><br /><font face="Times New Roman" size="2"> 
 dwnc=>\d custlo_temp;</font><br /><font face="Times New Roman" size="2">     Table "biosadm.custlo_temp"</font><br
/><fontface="Times New Roman" size="2">  Column  |     Type      | Modifiers</font><br /><font face="Times New Roman"
size="2">----------+---------------+-----------</font><br/><font face="Times New Roman" size="2"> lono     | text      
  |</font><br /><font face="Times New Roman" size="2"> lodate   | text          |</font><br /><font face="Times New
Roman"size="2"> rcvdate  | text          |</font><br /><font face="Times New Roman" size="2"> loamount | numeric(10,2)
|</font><br/><font face="Times New Roman" size="2"> custname | text          |</font><br /><font face="Times New Roman"
size="2"> status  | text          |</font><br /><br /><br /><font face="Times New Roman" size="2">My SELECT STATEMENT :
 </font><br/><br /><font face="Times New Roman" size="2"> dwnc=> insert into cust_lo_dim</font><br /><font
face="TimesNew Roman" size="2">dwnc-> (lo_no,lo_date,rcvdate,lo_status)</font><br /><font face="Times New Roman"
size="2">dwnc->select c.lono,c.lodate,c.rcvdate,c.status</font><br /><font face="Times New Roman" size="2">dwnc->
fromcustlo_temp c ;</font><br /><font face="Times New Roman" size="2">ERROR:  column "lo_date" is of type date but
expressionis of type text</font><br /><font face="Times New Roman" size="2">        You will need to rewrite or cast
theexpression</font><br /><font face="Times New Roman" size="2">Questions :</font><br /><br /><font face="Times New
Roman"size="2">  1)  How to rewrite /cast the expression above ???  same goes to others column .</font><br /><font
face="TimesNew Roman" size="2">2) lo_key is the column which values comes from sequence clo_seq. what should i do first
b4insert into cust_lo_dim ????</font><br /><br /><br /><font face="Times New Roman" size="2">i appreciate  for the
help.TQ</font> 

Re: Insert into

От
Gabriel Dovalo Carril
Дата:
El lun, 12-01-2004 a las 10:12, azwa@nc.com.my escribió:
>
> Hi,
> ..../....
>
> My SELECT STATEMENT :
>
> dwnc=> insert into cust_lo_dim
> dwnc-> (lo_no,lo_date,rcvdate,lo_status)
> dwnc-> select c.lono,c.lodate,c.rcvdate,c.status
> dwnc-> from custlo_temp c ;
> ERROR:  column "lo_date" is of type date but expression is of type
> text
>         You will need to rewrite or cast the expression
> Questions :
>
>   1)  How to rewrite /cast the expression above ???  same goes to
> others column .


Insert into cust_lo_dim
(lo_no, lo_date, rcvdate, lo_status)
select c.lono, c.lodate::date, c.rcvdate::date, c.status
from custlo_temp c;



> 2) lo_key is the column which values comes from sequence clo_seq. what
> should i do first b4 insert into cust_lo_dim ????

???
Nothing.
Are you getting some error?


--
Gabriel Dovalo