【发布时间】:2015-03-13 11:13:00
【问题描述】:
CREATE OR REPLACE PROCEDURE OM_TEST AS
CURSOR lcu_cust_site_ship (
p_cust_account_id IN NUMBER
, p_location_ship IN VARCHAR2
)
IS
SELECT HCSU.site_use_id
FROM hz_cust_site_uses_all HCSU, hz_cust_acct_sites_all CAS
WHERE HCSU.location = p_location_ship
AND HCSU.SITE_USE_CODE = 'SHIP_TO'
AND HCSU.cust_acct_site_id = CAS.cust_acct_site_id
AND CAS.cust_account_id = p_cust_account_id;
ln_cust_site_ship NUMBER:=0;
BEGIN
OPEN lcu_cust_site_ship (217162, lr_om_order_index.ship_to_location);
FETCH lcu_cust_site_ship INTO ln_cust_site_ship;
CLOSE lcu_cust_site_ship;
DBMS_OUTPUT.PUT_LINE ('lr_om_order_index.ship_to_location: '||lr_om_order_index.ship_to_location);
DBMS_OUTPUT.PUT_LINE ('ln_cust_site_ship: '||ln_cust_site_ship);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('ERROR IN SHIP TO LOCATION ');
END;
这里lr_om_order_index是一个记录索引,它包含运到位置的值。
现在得到的输出是
lr_om_order_index.ship_to_location:6698
ln_cust_site_ship:
运送到地点错误。
请帮助和指导我。我无法找出错误。
如果我在
中传递值 6698 而不是 lr_om_order_index.ship_to_location光标,那么它工作正常。
【问题讨论】:
-
您使用
when others不会让调试变得更容易。更改异常中的行,为您提供有意义的错误消息,例如:DBMS_OUTPUT.PUT_LINE ('ERROR IN SHIP TO LOCATION - '||SQLCODE||' - '||SQLERRM); -
好的,谢谢。现在输出是 ERROR IN SHIP TO_LOCATION - 100 ORA-01403: no data found.
-
请将整个代码包含在 lr_om_order_index 中 - 声明和打开的位置
-
HCSU.location 的类型是否与 lr_om_order_index.ship_to_location 匹配,或者是否发生了 NUMBER 到 VARCHAR 的隐式转换?
-
No Data Found基本上意味着某处有一个SELECT INTO语句不返回任何行。在这里完全摆脱异常块。您没有做任何有意义的事情来处理错误。至少这样你就能知道发生错误的行号。
标签: sql oracle plsql oracle11g