I'm having a problem with getting ORA-00942 errors, saying the table doesn't exist. It's true that it doesn't, but before the point I'm getting the errors at, it should be creating the table if it doesn't exist. Thus, when it gets to that point, the table should be there:
BEGIN
SELECT COUNT(*) INTO tCount
FROM user_tables
WHERE table_name='MY_TABLE';
IF tCount=0 THEN
EXECUTE IMMEDIATE 'CREATE TABLE MY_TABLE
(T_ID NUMBER(38,0),
T_DATE DATE,
T_COUNT NUMBER(38,0),
CONSTRAINT MY_TABLE_pk PRIMARY KEY (T_ID,T_DATE) )';
END IF;
LOOP
FOR idx IN 1 .. CursorTable.COUNT LOOP
SELECT COUNT(*) INTO pk_check
FROM MY_TABLE
WHERE T_ID=CursorTable(idx).T_ID AND T_DATE=CursorTable(idx).T_DATE;
IF (pk_check=0) THEN
INSERT INTO MY_TABLE
(T_ID,
T_DATE,
T_COUNT)
VALUES
(CursorTable(idx).T_ID,
CursorTable(idx).T_DATE,
CursorTable(idx).T_COUNT);
END IF;
END LOOP;
END LOOP;
END;
/