Title: Convert Cursor to array

Hi,

In a procedure, I put data of Cursor in a two-dimensional array. This allows me to sort rows.

The problem is this method is too slow.

In fact, I translate a pl/sql procedure to a plpgsql.
Under Oracle, we use bulk and I search to use equivalent of this under postgresql.

Is that exist ?

Oracle procedure

cursor childCursor is select * from CHILD WHERE......
....
open childCursor;
fetch childCursor bulk collect into children;
close childCursor;


Postgresql procedure :

FOR childRecord IN select * from nico.CHILD WHERE...
                LOOP
                -- on met les éléments dans le tableau
                children[recordcount] := '{'
                                                || childRecord.child_id || ','
                                                || childRecord.evolution || ','
                                                || childRecord.isremoved || ','
                                                || childRecord.child_class || ','
                                                || childRecord.indx || ','
                                                || childRecord.ele_id || ','
                                                || childRecord.doc_id ||
                                        '}';
               
                recordcount := recordcount + 1;
               
        END LOOP;


Bulk are native Oracle array and it is probably faster than array.
Is there native method postgresql to replace bulk ?

Best regards.

Reply via email to