簡體   English   中英

執行存儲過程時,在調用異常時獲取錯誤的數量或參數類型

[英]Getting wrong number or types of arguments in call to exception while executing stored procedure

我在oracle中創建了以下存儲過程。

CREATE OR REPLACE PROCEDURE "UPDATE_ASSET_LOB_PROC"(
asset_id IN integer,
distribution_id_list IN distribution_id)

IS
CURSOR dist_id
IS
select adt.lkp_dist_type from Asset_Dist_Type adt where adt.asset_id= asset_id;

BEGIN

  delete  from Asset_Dist_Type where asset_id= asset_id;
  commit;
  for i IN dist_id 
  LOOP
  insert into Asset_Dist_Type values (asset_id_list,i.lkp_dist_type);
  commit;
  END LOOP;

END UPDATE_ASSET_LOB_PROC;

distribution_是自定義類型。 我已經創建為

`CREATE TYPE distribution_id AS TABLE OF NUMBER;`

我的Java代碼如下。

Integer[] idArray = new Integer[selectedDistributionTypes.size()]; 
        idArray = selectedDistributionTypes.toArray(idArray); 

    entityManager.createNativeQuery("CALL UPDATE_ASSET_LOB_PROC (:assetIdParam,:distributionIdParam)")
                    .setParameter("assetIdParam", assetId).setParameter("distributionIdParam", idArray).executeUpdate();

我正進入(狀態

`Caused by: java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call to 'UPDATE_ASSET_LOB_PROC'`.

這是怎么了? 我想這是存儲過程。 但是我不太想寫存儲過程。 或者傳遞逗號分隔的列表並將其拆分為存儲過程是否可行?

得到了解決這個問題的方法。 我刪除了創建的自定義類型“ distribution id”,並將distribution_id_list設為varchar2。 我從bean中發送了一個逗號分隔的列表,並在存儲過程中刪除了逗號循環,如下所示。

SELECT REGEXP_SUBSTR (distribution_id_list, '[^,]+', 1,LEVEL) dist_id
                             FROM DUAL
                             CONNECT BY REGEXP_SUBSTR (distribution_id_list, '[^,]+', 1, LEVEL) IS NOT NULL

在for循環中,我可以對任何所需的操作使用dist_id。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM