When trying to run a procedure that takes an input value of XMLTYPE, the Set Parameters window shows the input as type UNDEFINED. Because of this, when trying to run it, it errors out:
PLS-00201: identifier UNDEFINED must be declared
Why is Toad not specifying XMLTYPE when the procedure defines it as XMLTYPE?
Toad shows it as UNDEFINED because the Oracle data dictionary doesnt support XMLTYPE so when we run the query to get the datatype, it show up as UNDEFINED.
Manually edit the Set Parameters Code window and change it from UNDEFINED to XMLTYPE, then provide the xml as expect.
Example:
CREATE OR REPLACE PROCEDURE show_xml (p_xml IN XMLTYPE)
IS
l_str LONG;
BEGIN
l_str := p_xml.EXTRACT (/*).getstringval ();
LOOP
EXIT WHEN l_str IS NULL;
DBMS_OUTPUT.put_line (SUBSTR (l_str, 1, INSTR (l_str, CHR (10)) - 1));
l_str := SUBSTR (l_str, INSTR (l_str, CHR (10)) + 1);
END LOOP;
END show_xml;
/
In the Set Parameters window, there is a section for Code. Manually define the data type and value there. It should look something like this:
DECLARE
P_XML XMLTYPE; -- change from UNDEFINED to XMLTYPE manually
BEGIN -- xml parameter entered below for P_XML in this sample
P_XML := xmltype (<?xml version=1.0 encoding=utf-8?><Employees><Employee>
<No>7369</No><Name>Smith</Name><Job>Clerk</Job></Employee><Employee>
<No>7499</No><Name>Allen</Name><Job>Salesman</Job></Employee><Employee>
<No>7521</No><Name>Ward</Name><Job>Salesman</Job></Employee></Employees>);
SHOW_XML ( P_XML );
COMMIT;
END;