Is there a way to use a FOR LOOP variable in a FUNCTION call. For example, I have a simple function that returns a string. I call the function from a procedure, and pass two parameters which one of the parameters is a variable from a FOR LOOP:
create or replace package body TEST_JNS is
--
FUNCTION f_display_msg(var IN VARCHAR2,
num IN NUMBER)
RETURN VARCHAR2 IS
BEGIN
--
RETURN num || '#: ' || var || ' world';
END f_display_msg;
--
--
PROCEDURE main
AS
l_name VARCHAR2(100);
l_id NUMBER;
BEGIN
l_name := 'hello';
--
FOR f1 IN (SELECT TO_NUMBER(TRIM(REGEXP_SUBSTR('1,2,3', '[^,]+', 1, LEVEL))) AS "id"
FROM DUAL
CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE('1,2,3', '[^,]+')) + 1)
LOOP
--
dbms_output.put_line(f_display_msg(l_name, f1.id));
--
END LOOP;
END main;
--
end TEST_JNS;
I get error: component 'ID' must be declared. I also tried adding the FOR LOOP value to a local variable, but get the same result. Any ideas?