create or replace PROCEDURE TASK_ADD
IS
CNT NUMBER;
BEGIN
FOR C IN (SELECT * FROM TAB WHERE TNAME LIKE 'TASK_EMAILS%' ORDER BY TNAME) LOOP
SELECT COUNT(*) INTO CNT
FROM USER_TAB_COLS
WHERE TABLE_NAME = C.TNAME
AND COLUMN_NAME = 'SEND_IP';
IF CNT = 0 THEN
EXECUTE IMMEDIATE ' ALTER TABLE '||C.TNAME||' ADD SEND_IP VARCHAR(15) ';
COMMIT;
END IF;
SELECT COUNT(*) INTO CNT
FROM USER_TAB_COLS
WHERE TABLE_NAME = C.TNAME
AND COLUMN_NAME = 'SENDER';
IF CNT = 0 THEN
EXECUTE IMMEDIATE ' ALTER TABLE '||C.TNAME||' ADD SENDER VARCHAR(64) ';
COMMIT;
END IF;
--DBMS_OUTPUT.PUT_LINE(C.TNAME) ;
--COMMIT;
END LOOP;
END;
IS
CNT NUMBER;
BEGIN
FOR C IN (SELECT * FROM TAB WHERE TNAME LIKE 'TASK_EMAILS%' ORDER BY TNAME) LOOP
SELECT COUNT(*) INTO CNT
FROM USER_TAB_COLS
WHERE TABLE_NAME = C.TNAME
AND COLUMN_NAME = 'SEND_IP';
IF CNT = 0 THEN
EXECUTE IMMEDIATE ' ALTER TABLE '||C.TNAME||' ADD SEND_IP VARCHAR(15) ';
COMMIT;
END IF;
SELECT COUNT(*) INTO CNT
FROM USER_TAB_COLS
WHERE TABLE_NAME = C.TNAME
AND COLUMN_NAME = 'SENDER';
IF CNT = 0 THEN
EXECUTE IMMEDIATE ' ALTER TABLE '||C.TNAME||' ADD SENDER VARCHAR(64) ';
COMMIT;
END IF;
--DBMS_OUTPUT.PUT_LINE(C.TNAME) ;
--COMMIT;
END LOOP;
END;