pruebalo así
Código SQL:
Ver originalCREATE OR REPLACE FUNCTION pa_validaruc(xruc text)
RETURNS INTEGER AS
$BODY$
DECLARE
i INTEGER;
residuo INTEGER;
ultdigito INTEGER;
aruc INTEGER[][] = array[[0,0,0,0,0,0,0,0,0,0,0]];
BEGIN
IF LENGTH(xruc)<>11 THEN
RETURN 0;
END IF;
FOR i IN 1..11 LOOP
aruc[1][i]:=CAST(SUBSTRING(xruc,i+1,1) AS INTEGER);
END LOOP;
RETURN 1;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
inicializando el array