-- 指定条件のTriggerを変更

DECLARE
  TYPE TriCurTyp  IS REF CURSOR;
  v_tri_cursor    TriCurTyp;
  tri_record      USER_TRIGGERS%ROWTYPE;
  v_stmt_str      VARCHAR2(200);
BEGIN
  -- Dynamic SQL statement with placeholder:
  v_stmt_str := 'SELECT * FROM USER_TRIGGERS WHERE TRIGGER_NAME LIKE :a AND STATUS <> ''ENABLED''';

  -- Open cursor and specify bind variable in USING clause:
  OPEN v_tri_cursor FOR v_stmt_str USING 'MAM%_R';

  -- Fetch rows from result set one at a time:
  LOOP
    FETCH v_tri_cursor INTO tri_record;
    EXIT WHEN v_tri_cursor%NOTFOUND;
    
    DBMS_OUTPUT.PUT_LINE('ALTER TRIGGER ' || tri_record.TRIGGER_NAME || ' ENABLE');
    EXECUTE IMMEDIATE 'ALTER TRIGGER ' || tri_record.TRIGGER_NAME || ' ENABLE';
  END LOOP;

  -- Close cursor:
  CLOSE v_tri_cursor;
END;
/
