在 Cursor PLSQL 过程中获取多个记录
Multiple Records being fetched in Cursor PLSQL Procedure
Table : WSH_DEL_DETAILS_INTERFACE
独一无二Column:DELIVERY_DETAIL_INTERFACE_ID
过程输入:DELIVERY_DETAIL_INTERFACE_ID
要获取的列值:SALES_ORDER_LINE_NUMBER , SALES_ORDER_NUMBER
预期输出:
单条记录
实际输出:
正在提取 table 中的所有记录
代码:
create or replace PROCEDURE procedurevalidation(
delivery_detail_interface_id IN
WSH_DEL_DETAILS_INTERFACE.DELIVERY_DETAIL_INTERFACE_ID%TYPE,
ROW_COUNT OUT INTEGER)
IS
CURSOR wddi_cur IS SELECT * FROM WSH_DEL_DETAILS_INTERFACE WHERE
DELIVERY_DETAIL_INTERFACE_ID = delivery_detail_interface_id;
wddi_record WSH_DEL_DETAILS_INTERFACE%ROWTYPE;
BEGIN
OPEN wddi_cur;
LOOP
FETCH wddi_cur into wddi_record;
EXIT when wddi_cur%NOTFOUND;
DBMS_OUTPUT.ENABLE(100000);
DBMS_OUTPUT.PUT_LINE(delivery_detail_interface_id);
DBMS_OUTPUT.PUT_LINE('SALESORDERNUMBER111:::: ' ||
wddi_record.SALES_ORDER_NUMBER);
DBMS_OUTPUT.PUT_LINE('SALESORDERLINENUMBER1111::::: ' ||
wddi_record.SALES_ORDER_LINE_NUMBER);
DBMS_OUTPUT.PUT_LINE('COUNT' || ROW_COUNT);
END LOOP;
CLOSE wddi_cur;
end;
您需要将输入变量的名称更改为您的过程。
create or replace PROCEDURE procedurevalidation(
p_delivery_detail_interface_id IN
WSH_DEL_DETAILS_INTERFACE.DELIVERY_DETAIL_INTERFACE_ID%TYPE,
ROW_COUNT OUT INTEGER)
并且在您的光标中,您还需要更改变量名称。
CURSOR wddi_cur
IS
SELECT *
FROM WSH_DEL_DETAILS_INTERFACE
WHERE DELIVERY_DETAIL_INTERFACE_ID = p_delivery_detail_interface_id;
您的光标正在返回 table 中的所有记录,因为您将 table 的列本身等同起来,而不是将其与过程中的输入变量匹配
Table : WSH_DEL_DETAILS_INTERFACE
独一无二Column:DELIVERY_DETAIL_INTERFACE_ID
过程输入:DELIVERY_DETAIL_INTERFACE_ID
要获取的列值:SALES_ORDER_LINE_NUMBER , SALES_ORDER_NUMBER
预期输出: 单条记录
实际输出: 正在提取 table 中的所有记录
代码:
create or replace PROCEDURE procedurevalidation(
delivery_detail_interface_id IN
WSH_DEL_DETAILS_INTERFACE.DELIVERY_DETAIL_INTERFACE_ID%TYPE,
ROW_COUNT OUT INTEGER)
IS
CURSOR wddi_cur IS SELECT * FROM WSH_DEL_DETAILS_INTERFACE WHERE
DELIVERY_DETAIL_INTERFACE_ID = delivery_detail_interface_id;
wddi_record WSH_DEL_DETAILS_INTERFACE%ROWTYPE;
BEGIN
OPEN wddi_cur;
LOOP
FETCH wddi_cur into wddi_record;
EXIT when wddi_cur%NOTFOUND;
DBMS_OUTPUT.ENABLE(100000);
DBMS_OUTPUT.PUT_LINE(delivery_detail_interface_id);
DBMS_OUTPUT.PUT_LINE('SALESORDERNUMBER111:::: ' ||
wddi_record.SALES_ORDER_NUMBER);
DBMS_OUTPUT.PUT_LINE('SALESORDERLINENUMBER1111::::: ' ||
wddi_record.SALES_ORDER_LINE_NUMBER);
DBMS_OUTPUT.PUT_LINE('COUNT' || ROW_COUNT);
END LOOP;
CLOSE wddi_cur;
end;
您需要将输入变量的名称更改为您的过程。
create or replace PROCEDURE procedurevalidation(
p_delivery_detail_interface_id IN
WSH_DEL_DETAILS_INTERFACE.DELIVERY_DETAIL_INTERFACE_ID%TYPE,
ROW_COUNT OUT INTEGER)
并且在您的光标中,您还需要更改变量名称。
CURSOR wddi_cur
IS
SELECT *
FROM WSH_DEL_DETAILS_INTERFACE
WHERE DELIVERY_DETAIL_INTERFACE_ID = p_delivery_detail_interface_id;
您的光标正在返回 table 中的所有记录,因为您将 table 的列本身等同起来,而不是将其与过程中的输入变量匹配