I have tried a few approaches. Those include:
exec plsql_procedure((select 'somestring' from dual));
EXECUTE IMMEDIATE ('testProc('''||(SELECT 'Testing' FROM dual)||''')');
EXECUTE IMMEDIATE ('EXEC testProc('''||(SELECT 'Testing' FROM dual)||''')');
None of the above worked. Looks like Oracle doesn't allow SELECT
statements in the arguments list under any circumstances.
One thing I did was store the SELECT
query result into a variable and use it later like follows:
CREATE OR REPLACE PROCEDURE testProc (
testVar IN VARCHAR2 -- Proc accepts VARCHAR2
) IS
BEGIN
dbms_output.put_line(testVar);
END;
/
SET SERVEROUTPUT ON
DECLARE
testVarIn VARCHAR(2000); -- Declare the variable
BEGIN
SELECT 'Testing' INTO testVarIn FROM dual;
-- Accept its value using SELECT ... INTO
testProc(testVarIn); -- Use the variable value to pass to the proc
END;
/
Output:
PROCEDURE testProc compiled
anonymous block completed
Testing
When things don't happen, we have to live with the alternatives. Our end goal is just to get the job done. It doesn't matter what we do for getting it done.