Convert Cursor to array

From: "GIROIRE Nicolas (COFRAMI)" <nicolas(dot)giroire(at)airbus(dot)com>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Convert Cursor to array
Date: 2005-03-11 13:03:09
Message-ID: 1904E3EB39448246A7ECB76DF34A70B0036A3F9A@TOCOMEXC03
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-03-11 13:05:28 Re: [GENERAL] more execution time
Previous Message Steven Verhoeven 2005-03-11 12:36:17 sql question