Search Postgresql Archives

plpgsql : looping over multidimensional array : getting NULL for subdimension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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';




--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux