mybatis框架,執行插入語句的時候,如果沒有字段傳過來就賦值為空 進行判斷


<insert id="insert" parameterType="com.ps.psdf.ScoreSettlePo">
        insert into t_score_settel
        (score_settel_id,
        member_code,
        order_no,
        product_code,
        product_name,
        pay_way,
        payable_amount,
        payable_score,
        consumer_date,
        consumer_org,
        sys_no,
        settel_type,
        remark,
        insert_time,
        insert_oper,
        update_time,
        update_oper)
        values
        (
        cast(#{scoreSettelId} as NUMERIC),
        #{memberCode},
        #{orderNo},
        #{productCode},
        #{productName},
        #{payWay},
        <choose>
            <when test="payableAmount != null and payableAmount != ''">
                cast(#{payableAmount} as NUMERIC),
            </when>
            <otherwise>
                null,
            </otherwise>
        </choose>

        <choose>
            <when test="payableScore != null and payableScore != ''">
                cast(#{payableScore} as NUMERIC),
            </when>
            <otherwise>
                null,
            </otherwise>
        </choose>
        #{consumerDate},
        #{consumerOrg},
        #{sysNo},
        #{settelType},
        #{remark},
        #{insertTime},
        #{insertOper},
        #{updateTime},
        #{updateOper})
    </insert>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM