- 论坛徽章:
- 0
|
想往TABLE中插入下列数据
2006-1-1 0 2006 200601 20060101
2006-1-1 1:00:00 1 2006 200601 20060101
2006-1-1 2:00:00 2 2006 200601 20060101
.....
2006-12-31 23:00:00 23 2006 200612 20061231
注:每天的第一条数据(零点) 没有0:00:00
即 插入的是:2006-1-1 而不是 2006-1-1 0:00:00
我写的:
CREATE PROCEDURE SP_TEST2()
define iCount int;
let iCount=1;
while (iCount<=8736)
insert into stat_lookup_day(hour_id,hour_desc,year_id,month_id,day_id)
values
( to_char(to_date('2006-01-01','yyyy-mm-dd hh:MM:ss')+iCount,'yyyy-mm-dd hh:MM:ss'),
to_char(to_date('2006-01-01','yyyy-mm-dd hh:MM:ss')+iCount,'HH'),
to_char(to_date('2006-01-01','yyyy-mm-dd hh:MM:ss')+iCount,'yyyy'),
to_char(to_date('2006-01-01','yyyy-mm-dd hh:MM:ss')+iCount,'yyyymm'),
to_char(to_date('2006-01-01','yyyy-mm-dd hh:MM:ss')+iCount,'yyyymmdd')
);
let iCount=iCount+1;
end while;
END PROCEDURE
有错误,请大家指正 |
|