Convert Cursor to array - Mailing list pgsql-general

From GIROIRE Nicolas (COFRAMI)
Subject Convert Cursor to array
Date
Msg-id 1904E3EB39448246A7ECB76DF34A70B0036A3F9A@TOCOMEXC03
Whole thread Raw
Responses Re: Convert Cursor to array
List pgsql-general

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.

pgsql-general by date:

Previous
From: Mike Harding
Date:
Subject: Data mining setup/hardware?
Next
From: Richard Huxton
Date:
Subject: Re: more execution time