insert into select 插入不进去数据
生活随笔
收集整理的這篇文章主要介紹了
insert into select 插入不进去数据
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼如下:
//大量數據的插入需要分批執行
while(!statistics_start.equals(init_date_from)){
String statistics_end=DateTool.getTimeStringDayPlus(statistics_start, +1);
? ? ? ? ? ? ? ? ? sql="insert into tb_request_month_temp ? (requesttime,username,devnumber,modulename,devtype,version)
(select requesttime,username,devnumber,modulename,devtype,version?
from v_request where REQUESTTIME >= to_date(?,'yyyy-MM-dd HH24:mi:ss') AND REQUESTTIME < to_date(?,'yyyy-MM-dd HH24:mi:ss'))";
PreparedStatement pstate=connDB.prepareStatement(sql);
try {
pstate.setString(1, statistics_start);
pstate.setString(2, statistics_end);
} catch (SQLException e) {
e.printStackTrace();
}
System.out.println(sql);
_log.info(sql);
try {
flag=pstate.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
if(flag==-1)return false;
statistics_start=DateTool.getTimeStringDayPlus(statistics_start, +1);
}
執行這段代碼,數據庫沒有數據,在數據庫里執行打印出來的sql語句有數據,
有哪位高手能看出代碼里的問題呢?為什么程序不能插入數據呢?
//大量數據的插入需要分批執行
while(!statistics_start.equals(init_date_from)){
String statistics_end=DateTool.getTimeStringDayPlus(statistics_start, +1);
? ? ? ? ? ? ? ? ? sql="insert into tb_request_month_temp ? (requesttime,username,devnumber,modulename,devtype,version)
(select requesttime,username,devnumber,modulename,devtype,version?
from v_request where REQUESTTIME >= to_date(?,'yyyy-MM-dd HH24:mi:ss') AND REQUESTTIME < to_date(?,'yyyy-MM-dd HH24:mi:ss'))";
PreparedStatement pstate=connDB.prepareStatement(sql);
try {
pstate.setString(1, statistics_start);
pstate.setString(2, statistics_end);
} catch (SQLException e) {
e.printStackTrace();
}
System.out.println(sql);
_log.info(sql);
try {
flag=pstate.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
if(flag==-1)return false;
statistics_start=DateTool.getTimeStringDayPlus(statistics_start, +1);
}
執行這段代碼,數據庫沒有數據,在數據庫里執行打印出來的sql語句有數據,
有哪位高手能看出代碼里的問題呢?為什么程序不能插入數據呢?
總結
以上是生活随笔為你收集整理的insert into select 插入不进去数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JAVA 17版本介绍(二)新特性介绍
- 下一篇: PyTorch学习笔记(四)Logist