我在Spring Repository中有以下方法,而执行异常是"具有该位置的参数[2]不存在"。我尝试了不同的选项来逃避单引号('),希望问题只与此有关。请建议。
@Query(value="select cus_acc_grp_i,"
+ " xmlquery ('$APP_CMP_WRK_XML/Root/CCPABusRuleAscList/CCPABusRuleAsc[position() >= (?2) and not(position() > (?3)) ]')"
+ " from ADM_APP_CMP_WRK where CUS_ACC_GRP_I = (?1)", nativeQuery=true)
AdministrationApplicationCompletion findCurrentPageRulesByClient(@Param("clientId") Integer customerAccountGroupId,
@Param("startIndex") Integer startIndex,
@Param("endIndex") Integer endIndex);
答案 0 :(得分:0)
@Smitha
你如何尝试以下内容:
@Query(value="select cus_acc_grp_i,"
+ " xmlquery ('$APP_CMP_WRK_XML/Root/CCPABusRuleAscList/CCPABusRuleAsc[position() >= (:startIndex) and not(position() > (:endIndex)) ]')"
+ " from ADM_APP_CMP_WRK where CUS_ACC_GRP_I = (:customerAccountGroupId)", nativeQuery=true)
AdministrationApplicationCompletion findCurrentPageRulesByClient(@Param("clientId") Integer customerAccountGroupId,
@Param("startIndex") Integer startIndex,
@Param("endIndex") Integer endIndex);
Pl让我知道这是否有效:)
答案 1 :(得分:0)
我们无法直接在XMLquery标量函数中定义参数,必须在xmlquery中使用PASSING来传递参数。以下是解决方案。
SELECT XMLQUERY(' // item [productName = $ n]' 通过PO.POrder, CAST(@hv AS INTEGER)AS" n")AS"结果" 来自PurchaseOrders PO;