互联网服务数据库

插入时间类型报错

db2 "insert into schemaname.test(mobile,paydate) values('12345697832', 2010-01-11-14.00.00.000000)"DB21034E  The command was processed as an SQL statement because it was not a valid Command Line Processor command.  During SQL proc...显示全部
db2 "insert into schemaname.test(mobile,paydate) values('12345697832', 2010-01-11-14.00.00.000000)"
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token ".00" was found following "4',
2010-01-11-14.00".  Expected tokens may include:  ",".  SQLSTATE=42601

其中paydate为TIMESTAMP类型。怎么插入会报这个错误?收起
参与4

查看其它 3 个回答leal402的回答

create table test(mobile varchar(11),paydate timestamp);
insert into test(mobile,paydate) values('12345697832', '2010-01-11-14.00.00.000000');

insert into test(mobile,paydate) values('12345697832', timestamp('2010-01-11-14.00.00.000000'));

select mobile,paydate from test;

select mobile,paydate from test;
completed successfully.

MOBILE       PAYDATE                     
-----------  --------------------------  
12345697832  2010-01-11 14:00:00.000000  
12345697832  2010-01-11 14:00:00.000000  

2 rows selected in 0.01 secs.

正确的做法是先将源用scalar函数转成目的类型。
2010-08-28
浏览384

回答者

leal402 最近回答过的问题

回答状态

  • 发布时间:2010-08-28
  • 关注会员:0 人
  • 回答浏览:384
  • X社区推广