item_id, pur_id, item_index, sku_id, sys.f_remove_zero(item_qty) as item_qty, price_std, amt_std, price_pur, item_amt, price_discount, non_std_code, into_status, sys.f_remove_zero(intoing_qty) as intoing_qty, intoing_amt, sys.f_remove_zero(into_qty) as into_qty, into_amt, sys.f_remove_zero(return_qty) as return_qty, return_amt, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user tppi.item_id, tppi.pur_id, tppi.item_index, tppi.sku_id, sys.f_remove_zero(tppi.item_qty) as item_qty, tppi.price_std as "pricePurchase", tppi.price_std, tppi.amt_std, tppi.price_pur, tppi.item_amt, tppi.price_discount, tppi.non_std_code, tppi.into_status, sys.f_remove_zero(tppi.intoing_qty) as intoing_qty, tppi.intoing_amt, sys.f_remove_zero(tppi.into_qty) as into_qty, tppi.into_amt, sys.f_remove_zero(tppi.return_qty) as return_qty, tppi.return_amt, tppi.remarks, tppi.flg_valid, tppi.cp_id, tppi.op_create_time, tppi.op_create_user_id, tppi.op_update_time, tppi.op_update_user_id, tppi.op_app_code, tppi.op_timestamp, tppi.op_db_user, tppi.from_id, tppi.from_item_id ,tppi.box ,tppi.piece ,tppi.unit_id ,tppi.sub_unit_id ,tppi.pack_box AND pur_id = #{purId}::uuid AND item_index = #{itemIndex} AND sku_id = #{skuId} AND item_qty = #{itemQty} AND price_std = #{priceStd} AND amt_std = #{amtStd} AND price_pur = #{pricePur} AND item_amt = #{itemAmt} AND price_discount = #{priceDiscount} AND non_std_code = #{nonStdCode} AND into_status = #{intoStatus} AND intoing_qty = #{intoingQty} AND intoing_amt = #{intoingAmt} AND into_qty = #{intoQty} AND into_amt = #{intoAmt} AND return_qty = #{returnQty} AND return_amt = #{returnAmt} AND remarks = #{remarks} AND flg_valid = #{flgValid} AND cp_id = #{cpId} AND op_create_time = #{opCreateTime} AND op_create_user_id = #{opCreateUserId} AND op_update_time = #{opUpdateTime} AND op_update_user_id = #{opUpdateUserId} AND op_app_code = #{opAppCode} AND op_timestamp = #{opTimestamp} AND op_db_user = #{opDbUser} AND tppi.pur_id = #{purId}::uuid AND tppi.item_index = #{itemIndex} AND tppi.sku_id = #{skuId} AND tppi.item_qty = #{itemQty} AND tppi.price_std = #{priceStd} AND tppi.amt_std = #{amtStd} AND tppi.price_pur = #{pricePur} AND tppi.item_amt = #{itemAmt} AND tppi.price_discount = #{priceDiscount} AND tppi.non_std_code = #{nonStdCode} AND tppi.into_status = #{intoStatus} AND tppi.intoing_qty = #{intoingQty} AND tppi.intoing_amt = #{intoingAmt} AND tppi.into_qty = #{intoQty} AND tppi.into_amt = #{intoAmt} AND tppi.return_qty = #{returnQty} AND tppi.return_amt = #{returnAmt} AND tppi.remarks = #{remarks} AND tppi.flg_valid = #{flgValid} AND tppi.cp_id = #{cpId} AND tppi.op_create_time = #{opCreateTime} AND tppi.op_create_user_id = #{opCreateUserId} AND tppi.op_update_time = #{opUpdateTime} AND tppi.op_update_user_id = #{opUpdateUserId} AND tppi.op_app_code = #{opAppCode} AND tppi.op_timestamp = #{opTimestamp} AND tppi.op_db_user = #{opDbUser} WHERE item_id in #{item} DELETE FROM dkic_b.t_psi_purchase_item WHERE item_id = #{id}::UUID; update dkic_b.t_psi_purchase_item return_qty= #{returnQty}, return_amt = #{returnAmt}, where item_id = #{itemId}::uuid update dkic_b.t_psi_purchase_item pur_id = #{et.purId,typeHandler=UuidTypeHandler}, item_index = #{et.itemIndex,jdbcType=INTEGER}, sku_id = #{et.skuId,typeHandler=UuidTypeHandler}, item_qty = #{et.itemQty,jdbcType=NUMERIC}, price_std = #{et.priceStd,jdbcType=NUMERIC}, amt_std = #{et.amtStd,jdbcType=NUMERIC}, price_pur = #{et.pricePur,jdbcType=NUMERIC}, item_amt = #{et.itemAmt,jdbcType=NUMERIC}, price_discount = #{et.priceDiscount,jdbcType=NUMERIC}, non_std_code = #{et.nonStdCode,jdbcType=VARCHAR}, into_status = #{et.intoStatus,jdbcType=VARCHAR}, intoing_qty = intoing_qty + #{et.intoingQty,jdbcType=NUMERIC}, intoing_amt = intoing_amt + #{et.intoingAmt,jdbcType=NUMERIC}, into_qty = into_qty + #{et.intoQty,jdbcType=NUMERIC}, into_amt = into_amt + #{et.intoAmt,jdbcType=NUMERIC}, return_qty = #{et.returnQty,jdbcType=NUMERIC}, return_amt = #{et.returnAmt,jdbcType=NUMERIC}, remarks = #{et.remarks,jdbcType=VARCHAR}, flg_valid = #{et.flgValid,jdbcType=BOOLEAN}, cp_id = #{et.cpId,jdbcType=INTEGER}, where item_id = #{et.itemId,typeHandler=UuidTypeHandler} and item_qty >= (into_qty + intoing_qty)