Error while trying to execute pl/sql that loops through a cursor containing only ROWID's

StackOverflow https://stackoverflow.com/questions/10199992

  •  01-06-2021
  •  | 
  •  

Вопрос

I'm trying to update all the columns in a given table. This table has ~200,000,000 records in it.

Trying to run a simple update statement doesn't work.

Here is my code:

DECLARE
    TYPE ROW_ID_TBL IS TABLE OF ROWID;
    CURSOR c_rowIdCursor RETURN ROWID IS
        SELECT ROWID FROM SOME_TABLE;

    v_RowIDs ROW_ID_TBL;
BEGIN
    OPEN c_rowIdCursor;
    LOOP
        FETCH c_rowIdCursor BULK COLLECT INTO v_RowIDs LIMIT 50000;
        EXIT WHEN v_RowIDs.COUNT = 0;

        FORALL i IN v_RowIDs.FIRST..v_RowIDs.LAST
            UPDATE SOME_TABLE
               SET SOME_KEY = MOD(NVL(REGEXP_REPLACE(ALPHA_NUMERIC_VAL, '[^0-9]+', ''), 0), 300)+1
             WHERE ROWID = v_RowIDs(i);
        COMMIT;
    END LOOP;
END;
/

I get the following when I try to run it:

ORA-06550: line 3, column 33:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 3, column 5:
PL/SQL: Item ignored
Это было полезно?

Решение

Your CURSOR definition is incorrect. You want something like

CURSOR c_rowIdCursor
    IS SELECT ROWID 
         FROM SOME_TABLE;

Of course, I'm not sure why a simply update wouldn't work. It would be more efficient, it would use fewer resources, and it would require less code.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top