互联网服务数据库

插入时间类型报错

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

4同行回答

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...显示全部
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
浏览379
mottemotte软件开发工程师广州BI公司
"PAYDATE" is not valid in the context where it is used.  SQLSTATE=42703显示全部
"PAYDATE" is not valid in the context where it is used.  
SQLSTATE=42703收起
互联网服务 · 2010-03-19
浏览369
leo_wynleo_wyn商业智能工程师Security
db2 "insert into schemaname.test(mobile,paydate) values('12345697832', '2010-01-11-14.00.00.000000')  -- 在timestamp 字段上添加''显示全部
db2 "insert into schemaname.test(mobile,paydate) values('12345697832', '2010-01-11-14.00.00.000000')  -- 在timestamp 字段上添加''收起
系统集成 · 2010-03-18
浏览335
leo_wynleo_wyn商业智能工程师Security
values (current timestamp) -- 检查一下当前timestamp的格式显示全部
values (current timestamp) -- 检查一下当前timestamp的格式收起
系统集成 · 2010-03-18
浏览359

提问者

motte
软件开发工程师广州BI公司
擅长领域: 数据库

相关问题

相关资料

相关文章

问题状态

  • 发布时间:2010-03-17
  • 关注会员:0 人
  • 问题浏览:3710
  • 最近回答:2010-08-28
  • X社区推广