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