<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 一、格式定義 映射文件方式調用存儲過程 的定義格式如下: ~~~ <procedure id="proc_id"> { proc_name( #{ param1 }, #{ param2 } , ......, #{ paramN } ) } </procedure> ~~~ 映射文件方式調用自定義的函數格式如下: ~~~ <procedure id="func_id"> { #{return} = func_name( #{ param1 }, #{ param2 } , ......, #{ paramN } ) } </procedure> 或 <procedure id="func_id"> { ?= func_name( #{ param1 }, #{ param2 } , ......, #{ paramN } ) } </procedure> -- 默認的函數值返回名稱為“return”. ~~~ ### 二、實例參考 存儲過程定義 ~~~ DROP PROCEDURE IF EXISTS proc_test_selectall; CREATE PROCEDURE proc_test_selectall (IN p_name varchar(30),OUT p_sum int) begin insert into test_book (book_name) values (p_name); select count(*) into p_sum from test_book; select * from test_book; end; ~~~ mapper定義 ~~~ <procedure id="test_102"> <![CDATA[ { call proc_test_selectall ( ? , #{sum | OUT } )} ]]> </procedure> ~~~ java代碼 ~~~ public class TestMapperProcedure { private MLinkMapper mlinkmapper = null; public TestMapperProcedure() { MLinkClient mlinkclient = new MLinkClient("http://localhost:8080"); this.mlinkmapper = new MLinkMapper(mlinkclient); } public void test102() throws DataAccessException { int random = (int)(1+Math.random()*(9999-1+1)); ResultMo rm = mlinkmapper.procedure("test_102", "name開發指南" + random); if (rm != null) { System.out.println(">>"+rm); System.out.println(">> sum = "+rm.getParameter("sum")); List<Object[]> list = rm.getList(); for (Object[] objs : list) { System.out.println(">> "+Arrays.toString(objs)); } } else { System.err.println(">> ResultMo rm 返回空值!"); } } public static void main(String[] args) { try { new TestMapperProcedure().test2(); } catch (DataAccessException e) { e.printStackTrace(); } } } ~~~ ### 三、實例參考集錦 默認輸入模式IN { call proc_test_insert ( ? ) } //僅是輸入值,需要用數組方式賦值 { call proc_test_insert ( #{name} ) } // 默認IN輸入模式 { call proc_test_insert ( #{name | OUT | VARCHAR} ) } //參數類型也可以明確指出。當然,默認為Java_Object就足夠了,一般情況下無需要指出。 { call proc_test_insert ( #{name | INOUT } ) } { call proc_test_insert ( 123, 456, #{name} ) } { call proc_test_insert ( 123, 456, #{name1}, #{name2}, #{name3 | OUT} ) } { ?= call func100 ( 123, 456 ) } // 默認返回值名稱 return { #{myname} = call func100 ( 123, 456, ) } //返回值名稱 myname import java.util.Arrays; import java.util.List; import cn.cantong.mlink.MLinkClient; import cn.cantong.mlink.MLinkMapper; import cn.cantong.mlink.exception.DataAccessException; import cn.cantong.mlink.mo.ResultMo; public class TestMapperProc { private MLinkMapper mlinkmapper = null; public TestMapperProc() { MLinkClient mlinkclient = new MLinkClient("http://localhost:8080"); this.mlinkmapper = new MLinkMapper(mlinkclient); } public void test101() throws DataAccessException { System.out.println("--------------------------------------------------"); System.out.println("插入 (name返回自增ID){ call proc_test_insert (#{name | INOUT } )}"); System.out.println("--------------------------------------------------"); int random = (int)(1+Math.random()*(9999-1+1)); ResultMo rm = mlinkmapper.procedure("test_101", "name", "Java開發指南" + random); if (rm != null) { System.out.println(">>"+rm); } else { System.err.println(">> ResultMo rm 返回空值!"); } } public void test102() throws DataAccessException { System.out.println("--------------------------------------------------"); System.out.println("插入 (返回sum和全部結果集){ call proc_test_selectall (? ,#{sum | OUT } )}"); System.out.println("--------------------------------------------------"); int random = (int)(1+Math.random()*(9999-1+1)); ResultMo rm = mlinkmapper.procedure("test_102", "name開發指南" + random); if (rm != null) { System.out.println(">>"+rm); System.out.println(">> sum = "+rm.getParameter("sum")); List<Object[]> list = rm.getList(); for (Object[] objs : list) { System.out.println(">> "+Arrays.toString(objs)); } } else { System.err.println(">> ResultMo rm 返回空值!"); } } public void test103() throws DataAccessException { System.out.println("--------------------------------------------------"); System.out.println("函數 (like查詢 return 返回結果) { ? = call func_get_count ( ? )}"); System.out.println("--------------------------------------------------"); ResultMo rm = mlinkmapper.procedure("test_103", "開發指南"); if (rm != null) { System.out.println(">>"+rm); System.out.println(">> return = "+rm.getParameter("return")); } else { System.err.println(">> ResultMo rm 返回空值!"); } } public static void main(String[] args) { try { new TestMapperProc().test101(); new TestMapperProc().test102(); new TestMapperProc().test103(); } catch (DataAccessException e) { e.printStackTrace(); } } }
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看