zoukankan      html  css  js  c++  java
  • 批量插入数据sql

    备份数据分为两步事务控制:批量插入和删除

    插入sql:

       public static final String SQL_BACKUP_DAILY_HISTORY_FORECAST_RESULT = "insert into sf_daily_fc_sales_bak(id,pm_info_id,merchant_id,product_id,category_id,fc_avg_price,page_price,fc_sales,real_sales,fc_effect,fc_except_type,create_time,stat_date,avg_his_sales,del_error_flag,pgm_code,model_id,forecast_date,event,is_oos,fc_sales_normal) " + "select  seq_sf_daily_fc_sales.nextval,pm_info_id,merchant_id,product_id,category_id,fc_avg_price,page_price,fc_sales,real_sales,fc_effect,fc_except_type,create_time,stat_date,avg_his_sales,del_error_flag,pgm_code,model_id,forecast_date,event,is_oos,fc_sales_normal from sf_daily_fc_sales where sf_daily_fc_sales.forecast_date <:backupHistoryDate";

    犯过一个很低级的错误,找了半天原因,org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLExce和缺少索引参数index ::1啥的错误~ ~ ~ ~

    关键点就在于我的sql里面参数前面的冒号跟参数间多了个空格!!!:  backupHistoryDate,真是大错特错。。。

    注:select seq_sf_daily_fc_sales.nextval的话备份后的id和查出的id不同,是自动生成的序列中的id,select id的话就和查出的id相同。

    删除sql:

        public static final String SQL_DELETE_DAILY_HISTORY_FORECAST_RESULT = "delete from sf_daily_fc_sales where forecast_date < :backupHistoryDate";

    细心编码,进步每一天~

  • 相关阅读:
    shell中括号的特殊用法 linux if多条件判断
    uboot kernel 博客
    meson 中调用shell script
    200. 岛屿数量
    9. 回文数
    53. 最大子序和
    394. 字符串解码
    32. 最长有效括号
    leetcode排序的题 912. 排序数组 215. 数组中的第K个最大元素
    c++引用和运算符重载思考
  • 原文地址:https://www.cnblogs.com/msr1019jingzi/p/3924787.html
Copyright © 2011-2022 走看看