private static String ADD_ATTR_EXT_ITEM="insert into attr_ext_item(attr_ext_main_key,attr_name_key,attr_type,data_type,mode,
                             tolerance,target_value,attr_lower_value,attr_higher_value,fetch_attr_group,
fetch_attr_name,calc_expression,serial_port,serial_port_baud_rate,serial_port_data_format,
pages)";
public boolean saveAttrExtItem(final List<AttrExtItem> listAttrExtItem,final int attrExtMainid) {
boolean result = true;
if (listAttrExtItem == null || listAttrExtItem.size() == 0)
return false;
StringBuffer buffer = new StringBuffer();
try {
buffer.append("begin;" );
for (int i = 0; i < listAttrExtItem.size(); i++) {
AttrExtItem att = listAttrExtItem.get(i);
buffer.append(ADD_ATTR_EXT_ITEM);
buffer.append(" values("
+attrExtMainid
+ ", " + att.getAttrNameKey()
+ ", '" + att.getAttrType()
+ "', '" + att.getDataType()
+ "', '" + att.getMode()
+ "', '" + att.getTolernace()
+ "', '" + att.getTargetValue()
+ "', '" + att.getAttrLowerValue()
+ "', '" + att.getAttrHigherValue()
+ "','" + att.getFetchAttrGroup()
+ "', '" + att.getFetchAttrName()
+ "', '" + att.getCalcExpression()
+ "', '" + att.getSerialPort()
+ "', " + att.getSerialPortbAUDRate()
+ ", '" + att.getSerialPortDataFormat()
+ "', '" + att.getPages()
+"'"+ ");");
}
buffer.append("commit;");
log.info("Add AttrExtItem sql: " + buffer.toString());
this.getJdbcTemplate2().update(buffer.toString());
} catch (Exception e) {
result = false;
log.error(e);
}
return result;
}

private static String ADD_ATTR_EXT_ITEM="insert into attr_ext_item(attr_ext_main_key,attr_name_key,attr_type,data_type,mode,tolerance,target_value,attr_lower_value,attr_higher_value,fetch_attr_group,fetch_attr_name,calc_expression,serial_port,serial_port_baud_rate,serial_port_data_format,pages)";public boolean saveAttrExtItem(final List<AttrExtItem> listAttrExtItem,final int attrExtMainid) {boolean result = true;if (listAttrExtItem == null || listAttrExtItem.size() == 0)return false;StringBuffer buffer = new StringBuffer();try {buffer.append("begin;" );for (int i = 0; i < listAttrExtItem.size(); i++) {AttrExtItem att = listAttrExtItem.get(i);buffer.append(ADD_ATTR_EXT_ITEM);buffer.append(" values("+attrExtMainid+ ", " + att.getAttrNameKey()+ ", '" + att.getAttrType()+ "', '" + att.getDataType()+ "', '" + att.getMode()+ "', '" + att.getTolernace()+ "', '" + att.getTargetValue()+ "', '" + att.getAttrLowerValue()+ "', '" + att.getAttrHigherValue()+ "','" + att.getFetchAttrGroup()+ "', '" + att.getFetchAttrName()+ "', '" + att.getCalcExpression()+ "', '" + att.getSerialPort()+ "', " + att.getSerialPortbAUDRate()+ ", '" + att.getSerialPortDataFormat()+ "', '" + att.getPages()+"'"+ ");");}buffer.append("commit;");log.info("Add AttrExtItem sql: " + buffer.toString());this.getJdbcTemplate2().update(buffer.toString());} catch (Exception e) {result = false;log.error(e);}return result;}

sql中批量插入begin的使用的更多相关文章

  1. C# 批量插入表SQLSERVER SqlBulkCopy往数据库中批量插入数据

    #region 帮助实例:SQL 批量插入数据 多种方法 /// <summary> /// SqlBulkCopy往数据库中批量插入数据 /// </summary> /// ...

  2. 向mysql中批量插入数据的性能分析

    MYSQL批量插入数据库实现语句性能分析 假定我们的表结构如下 代码如下   CREATE TABLE example (example_id INT NOT NULL,name VARCHAR( 5 ...

  3. SQL 2005批量插入数据的二种方法

    SQL 2005批量插入数据的二种方法 Posted on 2010-07-22 18:13 moss_tan_jun 阅读(2635) 评论(2) 编辑 收藏 在SQL Server 中插入一条数据 ...

  4. mybatis中批量插入的两种方式(高效插入)

    MyBatis简介 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及对结果集的检索封装.MyBatis可以使用 ...

  5. SQL中批量删除被注入的恶意代码的方法

    下文将为您介绍SQL中批量删除被注入的恶意代码的方法,供您参考,如果您也遇到了这样的问题,不妨一看,相信对您会有所帮助. 1,如果你的数据表很少的话,那么写几条简单的sql就搞定了 对于表中的nvch ...

  6. PL/SQL中批量执行SQL脚本(不可把所有的语句都复制到New SQL Windows)

    PL/SQL中批量执行SQL脚本,不可把所有的语句都复制到New SQL Window,因为这样会导致缓冲区过大而进程卡死! 最好的办法是将要执行的SQL脚本存放到指定文件中,如C:\insert.s ...

  7. MyBatis向数据库中批量插入数据

    Foreach标签 foreach: collection:指定要遍历的集合; 表示传入过来的参数的数据类型.该参数为必选.要做 foreach 的对象,作为入参时,List 对象默认用 list 代 ...

  8. sql server中批量插入与更新两种解决方案分享(存储过程)

    转自http://www.shangxueba.com/jingyan/1940447.html 1.游标方式 SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONG ...

  9. Oracle中批量插入

    为了防止OracleConnection的重复打开和关闭,使用begin end:将sql语句包在里面,然后一次性执行提高插入的效率. 下面代码中要插入的数据在list集合中,如果list集合的cou ...

随机推荐

  1. Spring Boot 项目实战(五)集成 Dubbo

    一.前言 上篇介绍了 Redis 的集成过程,可用于解决热点数据访问的性能问题.随着业务复杂度的提高,单体应用越来越庞大,就好比一个类的代码行数越来越多,分而治之,切成多个类应该是更好的解决方法,所以 ...

  2. Linux和window的区别

    免费与收费 最新正版Windows10官方售价¥888 Linux几乎免费(更多人愿意钻研开源软件,而收费的产品出现更多的盗版) 软件与支持 Windows平台:数量和质量的优势,补过大部分为收费软件 ...

  3. [LeetCode] Unique Morse Code Words 独特的摩斯码单词

    International Morse Code defines a standard encoding where each letter is mapped to a series of dots ...

  4. FastDFS 分布式文件系统的安装与使用(单节点)

    FastDFS 分布式文件系统的安装与使用(单节点) 跟踪服务器:192.168.4.121 (edu-dfs-tracker-01) 存储服务器:192.168.4.125 (edu-dfs-sto ...

  5. [Codeforces Round #438][Codeforces 868C. Qualification Rounds]

    题目链接:868C - Qualification Rounds 题目大意:有\(n\)个题目,\(k\)个人,每个人可能做过这\(n\)个题里的若干道,出题方要在这\(n\)个题目里选若干个出来作为 ...

  6. 最大流sap

    带当前弧优化 gap优化的sap 甚至省去了开始的bfs分层 虽然花了一些时间了解原理 但是感觉不亏 现在能完全独立靠原理写出具体实现了 #include<cstdio> #include ...

  7. [SDOI2009]SuperGCD

    题目链接 这题.高精度.恶心.难受. 那么高精度的gcd怎么做呢? 若a=b gcd(a,b)=a ①a偶b偶 gcd(a,b)=2*gcd(a/2,b/2) ②a偶b奇 gcd(a,b)=gcd(a ...

  8. SSM 记录

    前言:本过程从0开始,先是导入最核心的jar包,然后随着ssm中的功能实现,打包===>启动===>报错,一步步解决问题,增加额外的必须的jar包来熟悉ssm 1.导包(核心包) myba ...

  9. 电子产品使用感受之——我的Mac只有256GB,我的照片库该怎么办?

    说实话我使用过的Mac中最大的默认存储可能就是2011年开始使用的MacBook Pro了,机器型号大概是MC700,这台机器当年自带320GB 5400转机械硬盘,直到2016年因为使用率太高,机械 ...

  10. How to set font and colors of Eclipse UI

    The original URL of this article is https://codeyarns.com/2014/11/03/how-to-set-font-and-font-size-o ...