From:       To:      

Home > Documentation > Oracle to PostgreSQL

Cursors

Both Oracle and PostgreSQL use cursors to encapsulate a query and process every individual row. However, there are minor syntax differences that must be handled properly during migration from Oracle to PostgreSQL:

Oracle allows to iterate rows in cursor using the following cycle:

FOR record_variable IN cursor_variable 
LOOP
    ...
END LOOP;

In PostgreSQL the following construction may be used for the same purpose:

LOOP
    FETCH FROM cursor_variable INTO record_variable;
    EXIT WHEN NOT FOUND;
    ...
END LOOP;

Have questions? Contact us