Gilberto Castillo Martínez wrote:
Colegas:

Intento hacer lo siguiente:

CREATE OR REPLACE FUNCTION mira (nom_table character, pk_parent integer)
  RETURNS bigint AS
$BODY$
DECLARE
cant bigint;
BEGIN
EXECUTE 'SELECT count(*) INTO cant FROM '|| quote_ident (nom_table)||'
WHERE id='||pk_parent; ---||';';
RETURN cant;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;


Hasta ahí todo bien.

Cuando lanzo lo siguinte.

select mira ('pais', 5);


ERROR:  EXECUTE of SELECT ... INTO is not implemented yet
CONTEXTO:  PL/pgSQL function "mira" line 4 at EXECUTE statement

Según leí es un problemas de implementación de EXECUTE para versiones
anteriores, Tengo instalado 8.3.7

¿Qué debo activar?


No necesitas activar nada y no necesitas utilizar EXECUTE para asignar un valor a la variable cant.

Podrias intentar algo parecido a esto:

CREATE OR REPLACE FUNCTION mira (nom_table character, pk_parent integer)
  RETURNS bigint AS
$BODY$
DECLARE
cant bigint;
BEGIN
SELECT INTO cant cnt FROM (SELECT count(*) AS cnt FROM quote_ident (nom_table) WHERE id= pk_parent) value;
RETURN cant;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

Ya contaras
--
 Rafael Martinez, <r.m.guerr...@usit.uio.no>
 Center for Information Technology Services
 University of Oslo, Norway

 PGP Public Key: http://folk.uio.no/rafael/
--
TIP 9: visita nuestro canal de IRC #postgresql-es en irc.freenode.net

Responder a