PL/PGSQL - ERROR: invalid array subscripts

From: "Froggy / Froggy Corp(dot)" <froggy(at)froggycorp(dot)com>
To: "pgsql-fr-generale(at)postgresql(dot)org" <pgsql-fr-generale(at)postgresql(dot)org>
Subject: PL/PGSQL - ERROR: invalid array subscripts
Date: 2005-02-17 19:18:20
Message-ID: 4214EDFC.606A76B7@froggycorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale

Bonjour,

Je testais les matrices en PL/PGSQL et je suis tombe sur le cas d'une
matrice vierge sans limitation de valeur avec definition en mode non
incremental.
J'ai donc teste la fonction ci-dessus et je recupere l'erreur suivante
:
"ERROR: invalid array subscripts"
CONTEXT: PL/pgSQL function "test_array" line 16 at assignment

-------------------------------------------------------------------------

CREATE OR REPLACE FUNCTION test_array() RETURNS integer AS '
DECLARE
a integer;
b integer;
c integer;
array varchar[];
BEGIN

array := ''{}'';

a := 1;
WHILE a < 17 LOOP
b := 1;
WHILE b < 17 LOOP
c:= a + b * 16;
RAISE NOTICE ''%'', c;
array[c] := ''&'';
b := b + 1;
END LOOP;
a := a + 1;
END LOOP;

return 0;

END;
' LANGUAGE plpgsql;

-----------------------------------------------

Le RAISE NOTICE est juste là à titre de debuggage, détail amusant, la
ligne "c:= a + b * 16;" était avant "c:= a + b * a;" et là cela
fonctionnait (enfin l'algo était faux) et pourtant ne remplissait pas
mon array en incrementiel.

Je suis actuellement en 7.4, si quelqu'un avait la 8.0 de deja installer
et pouvait tester et pouvait me remonter l'info ? Ou me donner la
solution ;)

Merci d'avance,
+

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Guillaume BARTHE 2005-02-18 10:05:36 Re: Espace disque et postgresql
Previous Message Erwan DUROSELLE 2005-02-16 15:48:53 Rép. : Espace disque et postgresql