CREATE OR REPLACE PROCEDURE show_recm (in_task_name IN VARCHAR2) 
IS
  CURSOR curs IS
      SELECT DISTINCT action_id, command, attr1, attr2, attr3, attr4
      FROM user_advisor_actions
      WHERE task_name = in_task_name
      ORDER BY action_id;

  v_action number;
  v_command VARCHAR2(32);
  v_attr1 VARCHAR2(4000);
  v_attr2 VARCHAR2(4000);
  v_attr3 VARCHAR2(4000);
  v_attr4 VARCHAR2(4000);
  v_attr5 VARCHAR2(4000);
BEGIN
  OPEN curs;
  DBMS_OUTPUT.PUT_LINE('=========================================');
  DBMS_OUTPUT.PUT_LINE('Task_name = ' || in_task_name);
  LOOP
      FETCH curs INTO v_action, v_command, v_attr1, v_attr2, v_attr3, v_attr4;
      EXIT when curs%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE('Action ID: ' || v_action);
      DBMS_OUTPUT.PUT_LINE('Command : ' || v_command);
      DBMS_OUTPUT.PUT_LINE('Attr1 (name) : ' || SUBSTR(v_attr1,1,30));
      DBMS_OUTPUT.PUT_LINE('Attr2 (tablespace): ' || SUBSTR(v_attr2,1,30));
      DBMS_OUTPUT.PUT_LINE('Attr3 : ' || SUBSTR(v_attr3,1,30));
      DBMS_OUTPUT.PUT_LINE('Attr4 : ' || v_attr4);
      DBMS_OUTPUT.PUT_LINE('Attr5 : ' || v_attr5);
      DBMS_OUTPUT.PUT_LINE('----------------------------------------');
  END LOOP;
  CLOSE curs;
  DBMS_OUTPUT.PUT_LINE('=========END RECOMMENDATIONS============');
END show_recm;
/
