plpgsql : looping over multidimensional array : getting NULL for subdimension - Mailing list pgsql-general

From Vinicio Nocciolini
Subject plpgsql : looping over multidimensional array : getting NULL for subdimension
Date
Msg-id 51B0A054.40603@mbigroup.it
Whole thread Raw
In response to plpgsql : looping over multidimensional array : getting NULL for subdimension  (Samba <saasira@gmail.com>)
List pgsql-general
Use array_upper(aList, 2);
see the example, maybe can help u


CREATE OR REPLACE FUNCTION
xxx(
     aList varchar[][])
returns TEXT as '
declare
     myUpper1 integer;
     myUpper2 integer;

     myRet varchar := '''';
begin
     myUpper1 := array_upper(aList, 1);
     IF myUpper1 IS NULL THEN
         myUpper1 := 0;
     END IF;
     myUpper2 := array_upper(aList, 2);
     IF myUpper2 IS NULL THEN
         myUpper2 := 0;
     END IF;

     FOR i in 1 .. myUpper1 LOOP
         FOR k in 1 .. myUpper2 LOOP
             myRet := myRet || aList[i][k];
         END LOOP;
         myRet := myRet || ''_'';
     END LOOP;

     RETURN myRet;
end;
'
LANGUAGE 'plpgsql';




pgsql-general by date:

Previous
From: François Beausoleil
Date:
Subject: Slave promotion failure
Next
From: Jeff Janes
Date:
Subject: Re: Trouble with replication