ibatis对存储过程的调用
2010-05-05 14:23
211 查看
IBatis映射文件:
DAO层代码:
存储过程:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" > <sqlMap namespace="BUSSINESS_B_T_PRODUCT" > <parameterMap id="hasAuthParam" class="java.util.HashMap" > <parameter property="p_productCode" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/> <parameter property="p_customerId" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/> <parameter property="p_callType" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/> <parameter property="p_total" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/> <parameter property="result" jdbcType="INTEGER" javaType="java.lang.Integer" mode="INOUT"/> </parameterMap> <procedure id="hasAuth" parameterMap="hasAuthParam" > <!--[CDATA[ {call BUSINESSES_HAS_AUTH(?,?,?,?,?)} ]]--> </procedure> </sqlMap>
DAO层代码:
public Integer hasAuth(String productCode, Long customerId,String callType,Long total){ Map<String,Object> map = new HashMap<String,Object>(); map.put("p_productCode", productCode); map.put("p_customerId", customerId); map.put("p_callType", callType); map.put("p_total", total); map.put("result", -1); queryData("BUSSINESS_B_T_PRODUCT.hasAuth", map); Integer result = (Integer)map.get("result"); System.out.println(result); return Integer.valueOf(result); }
存储过程:
CREATE OR REPLACE PROCEDURE GBOSS.BUSINESSES_HAS_AUTH (p_productCode IN VARCHAR2, p_customerId IN number, p_callType IN VARCHAR2,p_total in number,result out integer) is v_count integer; v_stateCount integer; v_seviceTypeState varchar(1); v_outstanding C_T_CUSTOMER.OUTSTANDING%type; v_billingModel C_T_CUSTOMER_PRODUCT.CP_BILLING_MODEL%type; v_unitPrice C_T_CUSTOMER_PRODUCT.UNIT_PRICE%type; v_cpId C_T_CUSTOMER_PRODUCT.CP_ID%type; v_currConsu C_T_CUSTOMER_PRODUCT.Curr_Consu%type; v_q C_T_BLXS_PRICING.q%type; v_p2 C_T_BLXS_PRICING.P2%type; BEGIN result:=0; select count(1) into v_count from C_T_CUSTOMER_PRODUCT cp,B_T_PRODUCT p,C_T_SERVICE_TYPE t where p.PRODUCT_ID=cp.PRODUCT_ID and cp.CP_ID=t.CP_ID and cp.OPER_STATE='1' and t.ST_SERVICE_TYPE=p_callType and p.PRODUCT_CODE=p_productCode and cp.CUSTOMER_ID=p_customerId; if v_count=0 then result:=41 ; elsif v_count>1 then result:=42 ; elsif v_count=1 then select t.ST_SERVICE_TYPE_STATE,c.OUTSTANDING,cp.CP_BILLING_MODEL,cp.UNIT_PRICE,cp.cp_id,cp.curr_consu into v_seviceTypeState,v_outstanding,v_billingModel,v_unitPrice,v_cpId,v_currConsu from C_T_CUSTOMER_PRODUCT cp,B_T_PRODUCT p,C_T_SERVICE_TYPE t,C_T_CUSTOMER c where p.PRODUCT_ID=cp.PRODUCT_ID and cp.CP_ID=t.CP_ID and cp.OPER_STATE='1' and t.ST_SERVICE_TYPE=p_callType and p.PRODUCT_CODE=p_productCode and cp.CUSTOMER_ID=p_customerId and c.CUSTOMER_ID=cp.CUSTOMER_ID; if v_seviceTypeState='2' then select count(1) into v_stateCount from C_T_CUSTOMER_PRODUCT cp,B_T_PRODUCT p,C_T_SERVICE_TYPE t where p.PRODUCT_ID=cp.PRODUCT_ID and cp.CP_ID=t.CP_ID and cp.OPER_STATE='1' and t.ST_SERVICE_TYPE=p_callType and p.PRODUCT_CODE=p_productCode and cp.CUSTOMER_ID=p_customerId and t.ST_SERVICE_TYPE_STATE ='2' and cp.CP_INF_BONUS>cp.CP_INF_USE; if v_stateCount>0 then result:=3; else result:=43; end if; elsif v_seviceTypeState='3' then select count(1) into v_stateCount from C_T_CUSTOMER_PRODUCT cp,B_T_PRODUCT p,C_T_SERVICE_TYPE t where p.PRODUCT_ID=cp.PRODUCT_ID and cp.CP_ID=t.CP_ID and cp.OPER_STATE='1' and t.ST_SERVICE_TYPE=p_callType and p.PRODUCT_CODE=p_productCode and cp.CUSTOMER_ID=p_customerId and t.ST_SERVICE_TYPE_STATE ='3' and cp.CP_DATA_BONUS>cp.CP_DATA_USE; if v_stateCount>0 then result:=4; else result:=44; end if; end if; end if; exception when others then result := 48; END;
相关文章推荐
- IBatis.Net学习笔记(七):在IBatis.Net中调用存储过程
- Ibatis调用存储过程
- javaEE--ibatis--Sping+flex4 调用存储过程返回List结果集
- IBatis.Net学习笔记(七):在IBatis.Net中调用存储过程
- Ibatis调用存储过程(笔记)
- ibatis-调用存储过程
- java代码在ibatis里调用存储过程配置
- ibatis调用存储过程(带输出参数的存储过程)
- 新的开始之Ibatis 整合Spring 调用存储过程
- ibatis通过Map封装参数调用存储过程
- Ibatis调用存储过程实现增删改以及分页查询
- ibatis 调用存储过程
- 使用 iBatis 调用存储过程并返回值
- ibatis调用存储过程
- ibatis调用存储过程,且返回的结果集不确定列数
- 极为简单的Spring+Ibatis调用存储过程
- iBatis调用返回两个游标的存储过程处理方法
- ibatis对存储过程的调用
- Ibatis编程--调用存储过程
- iBatis调用存储过程