Java世界

          學(xué)習(xí)筆記

          常用鏈接

          統(tǒng)計(jì)

          積分與排名

          天籟村

          新華網(wǎng)

          雅虎

          最新評(píng)論

          批量插入(Test)

          1. <insert id="insertData" parameterType="java.util.List" >  
          2.         INSERT INTO EMP(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO) (  
          3.         <foreach collection="list" item="item" index="index" separator="union all">  
          4.             select  
          5.                 #{item.EMPNO,jdbcType=VARCHAR},  
          6.                 #{item.ENAME,jdbcType=VARCHAR},  
          7.                 #{item.JOB,jdbcType=VARCHAR},  
          8.                 #{item.MGR,jdbcType=NUMERIC},  
          9.                 #{item.MGR,jdbcType=NUMERIC},  
          10.                 TO_DATE(#{item.HIREDATE,jdbcType=VARCHAR},'yyyy-mm-dd')  
          11.                   from dual  
          12.         </foreach>  
          13.         )  
          14. </insert> 

            =====================================================================


            declare    
              type t_array is table of t_target%rowtype;    
              t_data t_array;    
              cursor c is    
                select null id, owner, object_name, null object_id, null xx, null yy    
                from dba_objects;    
            begin    
              open c;    
              loop    
                fetch c bulk collect    
                into t_data limit 100;    
                
                forall i in 1 .. t_data.count    
                  insert into t_target values t_data (i);    
                exit when c%notfound;    
              end loop;    
              close c;    
              commit;    
            end; 



            <insert id="insertByProc" statementType="CALLABLE">         
            {call insertPro(#{name},#{age},#{sex},#{password},#{num})}

            </insert>

            1 CREATE DEFINER = `root`@`localhost` PROCEDURE `NewProc`(IN `name_in` varchar(255),IN `age_in` int,IN `sex_in` varchar(255),IN `password_in` varchar(255),IN `num_in` int)  2 BEGIN  3     SET @a=0;  4 Label:LOOP  5     SET @a=@a+1;  6     INSERT INTO person ( name, age, sex, password) VALUES (name_in,age_in,sex_in,password_in);  7      IF @a=num_in THEN  8             LEAVE Label;  9         END IF; 10 END LOOP Label; 11 END;

          posted on 2014-04-15 21:38 Rabbit 閱讀(1155) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 中方县| 沅江市| 东方市| 潼南县| 鲁山县| 盘锦市| 邛崃市| 寿宁县| 介休市| 莆田市| 赣榆县| 遵义县| 靖西县| 通山县| 丁青县| 麻栗坡县| 军事| 亳州市| 柳河县| 英吉沙县| 宜川县| 松溪县| 廊坊市| 蓬安县| 赤水市| 邢台市| 雷山县| 桓台县| 云南省| 牙克石市| 麻江县| 阜平县| 缙云县| 龙陵县| 桃园县| 宁河县| 文成县| 驻马店市| 邵东县| 桂平市| 紫金县|