Java世界

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

          常用鏈接

          統(tǒng)計

          積分與排名

          天籟村

          新華網(wǎ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) 評論(0)  編輯  收藏


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 泰兴市| 揭阳市| 盐池县| 南京市| 仙游县| 温泉县| 宝坻区| 饶平县| 仪征市| 吴川市| 冕宁县| 娱乐| 阿拉善盟| 盐亭县| 甘德县| 卢龙县| 股票| 宁陕县| 天水市| 乳源| 色达县| 济源市| 农安县| 日土县| 衡阳县| 苏尼特右旗| 会同县| 临安市| 外汇| 东辽县| 梓潼县| 白山市| 北海市| 旅游| 铅山县| 克拉玛依市| 花垣县| 阿坝县| 六盘水市| 阿图什市| 五台县|