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. SpringBoot2 task scheduler 定时任务调度器四种方式

    github:https://github.com/chenyingjun/springboot2-task 使用@EnableScheduling方式 @Component @Configurabl ...

  2. 转载:使用Tornado+Redis维护ADSL拨号服务器代理池

    我们尝试维护过一个免费的代理池,但是代理池效果用过就知道了,毕竟里面有大量免费代理,虽然这些代理是可用的,但是既然我们能刷到这个免费代理,别人也能呀,所以就导致这个代理同时被很多人使用来抓取网站,所以 ...

  3. BigDecimal 准确的 double , float 计算

    public class ArithUtil { private static final int DEF_DIV_SCALE = 10; private ArithUtil() { } /** * ...

  4. Go数组求和

    package main import "fmt" ]int func main() { a := [],,,,} var b int for index,value := ran ...

  5. 傅里叶变换及其应用讲义(stanford_ee261)

    链接:http://pan.baidu.com/s/1bprVIqF 密码:q5iv

  6. jquery常用语句

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. 第一次c++作业小结

    之前从未接触过c++,上完第一节课后也还是懵懵懂懂.当知道有作业要完成时,也是无从下手.在仔细阅读教材以及同学的帮助下,我了解了如何编写最简单的程序,也算是踏入c++的大门.希望自己的第一次作业能够符 ...

  8. snmp简单测试

    一.环境搭建 搜索windows Server2003安装配置snmp 服务,按照提示来就行 二.利用 1.找出Coummunity Strings 利用于 auxiliary/scanner/snm ...

  9. request之LIstener监听器

    要实现监听request内置对象,必须实现一个接口javax.servlet.ServletRequsetListener. 代码如下: package cn.wangkai.listener; im ...

  10. PHP 多个构造函数

    class A { function __construct() { $a = func_get_args(); $i = func_num_args(); if (method_exists($th ...