I have this procedure which just deletes a row based on a column field called AppID
. This procedure get's a value from another column called AppNbr
based on that rows AppID
column. The procedure is failing with a TOO_MANY_ROWS
exception when it tries to SELECT
a row. This is the PL/SQL:
DECLARE
lvnApplNbr NUMBER;
PROCEDURE deleteAppl(applId IN VARCHAR2) IS
BEGIN
BEGIN
SELECT ApplNbr -- Exception thrown here
INTO lvnApplNbr
FROM Appl
WHERE ApplID = applId;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- ... Delete it after some logic
END; -- End Procedure
BEGIN
...
deleteAppl('571E00BA-70E6-4523-BEAC-4568C3DD1A7D');
...
END;
The TOO_MANY_ROWS
exception is thrown when it SELECT INTO
s. I have no idea why it is throwing that error because if I just query this:
SELECT ApplNbr FROM Appl WHERE ApplId = '571E00BA-70E6-4523-BEAC-4568C3DD1A7D';
Only one row will come back with the correct ApplId
.
What is going on?