I need to execute a dynamic query.
I need to extract some values of a table. With these a values I can construct the table names where I must do another query and check every value that it gives me with a if clause.
I'm trying to make with cursor, but it seems don't let me put a variable in the second cursor.
What is the best method to do this. Could you help me please?
DECLARE CURSOR c_outer IS SELECT ACTIVE FROM COMM; CURSOR c_inner(p_name VARCHAR2) IS SELECT (sysdate-to_date(START_TIME,'YYYYMMDDHH24MISS'))*24 HOURS FROM p_name WHERE UPPER(STATUS) = 'EXECUTING'; HOURS NUMBER; TAB VARCHAR2(30); BEGIN FOR r IN c_outer LOOP TAB :='A'||c_outer||'JOB'; OPEN c_inner(TAB); FETCH c_inner INTO HOURS; IF HOURS > 24 THEN DBMS_OUTPUT.PUT_LINE('MAXIMMO'); END IF; CLOSE c_inner; END LOOP; END;