mysql xml 参数

drop PROCEDURE IF EXISTS tt;
CREATE PROCEDURE tt(
para text,
OUT para1 DECIMAL(18, 6),
OUT para2 DECIMAL(18, 6)
)
BEGIN
    DECLARE Count int;
    DECLARE i int;

    DECLARE v_id int;
    DECLARE v_insurance_amount DECIMAL(18, 6);
    DECLARE v_rate DECIMAL(18, 6);

    SET i = 1;
    SET Count = ExtractValue(para, 'count(/list/com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance/id)');
    WHILE i <= Count DO
            SET v_id = ExtractValue(para, '/list/com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance[$i]/id');
            SET v_insurance_amount = ExtractValue(para, '/list/com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance[$i]/insurance_amount');
            SET v_rate = ExtractValue(para, '/list/com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance[$i]/rate');
            IF v_id = 1 THEN
                SET para1 = v_insurance_amount * v_rate;
            END IF;
            IF v_id = 2 THEN
                SET para2 = v_insurance_amount * v_rate;
            END IF;
        SET i = i + 1;
    END WHILE;
end;


call tt('<list>
  <com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance>
    <id>1</id>
    <insurance_amount>1000</insurance_amount>
    <rate>0.35</rate>
    <premium_amount>0.0</premium_amount>
  </com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance>
  <com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance>
    <id>2</id>
    <insurance_amount>300</insurance_amount>
    <rate>0.4</rate>
    <premium_amount>0.0</premium_amount>
  </com.xk.insalesystem.pojo.premiumCalculation.HouseholdPropertyAddtionalInsurance>
</list>', @a, @b);
SELECT @a, @b;

转载于:https://www.cnblogs.com/zisezhixin/p/5125671.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值