I am trying to create a function that dynamically runs a query based on inputs. The first input for the function, input_id, is the argument for the dynamic query. The second input, IN_QUERY_ID, specifies which query to use.
create or replace
FUNCTION getResultID(
INPUT_ID NUMBER,
IN_QUERY_ID NUMBER
)
RETURN VARCHAR2
AS
RESULT_ID VARCHAR2(256);
query_str VARCHAR2(256);
BEGIN
select CONSTRUCTOR INTO query_str from query_str_ref
where QUERY_ID=IN_QUERY_ID;
EXECUTE IMMEDIATE query_str INTO RESULT_ID USING INPUT_ID;
RETURN Result_ID;
END getResultID;
I'm getting an error that I'm not properly ending the statement after "RESULT_ID=IN_QUERY_ID;" I'm wondering if I'm missing some other step.
DBMS_OUTPUT.PUT_LINE(INPUT_ID);andDBMS_OUTPUT.PUT_LINE(query_str);executecommand, which is strange.