Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/10/2011, 08:32
Avatar de djmashe
djmashe
 
Fecha de Ingreso: julio-2007
Ubicación: Posadas, Misiones
Mensajes: 52
Antigüedad: 16 años, 10 meses
Puntos: 2
De acuerdo Respuesta: array_length en postgres 8.3

Gracias huesos52 por la rta. A continuacion dejo el script con la solucion:

Código SQL:
Ver original
  1. -- Function: texto_array()
  2. DROP FUNCTION IF EXISTS texto_array();
  3. CREATE OR REPLACE FUNCTION texto_array()
  4.   RETURNS text AS
  5. $BODY$
  6. DECLARE
  7.   arreglo text[];
  8.   total INTEGER := 0;
  9. BEGIN
  10.   arreglo := array[1,2,3];
  11.  
  12.   total := array_upper(arreglo, 1) - array_lower(arreglo, 1) + 1;
  13.   raise notice 'Total elementos: %', total;
  14.  
  15.   FOR i IN 1 .. total LOOP                      -- version < 8.4
  16.   --FOR i IN 1..(array_length(arreglo, 1)) LOOP -- version > 8.4
  17.     raise notice '%', i;
  18.   END LOOP;
  19.   RETURN TRUE;
  20. END;
  21. $BODY$
  22. LANGUAGE 'plpgsql';
  23. ALTER FUNCTION texto_array() OWNER TO postgres;