Hola Emanuel
2009/11/27 suso <jlcu...@terra.es>:
Hola de nuevo, por favor, a ver si alguien me puede decir pq no funciona
ésta consulta, incluso si la ejecuto dede pgadmin, postgres 8.4 y windows
xp.

select count(*) into devuel from clientes where apell like '" || apelli ||
"%'

select count(*) into devuel from clientes where apell like 'P%'

Esto si funciona, si hago su "equivalente" desde vb6 va sin problemas.
Otros colisteros me han dicho variantes, pero ninguna va.
por ejemplo:

select count(*) into devuel from clientes where apell like '" & apelli & "%'
select count(*) into devuel from clientes where apell like ' & apelli & %'
select count(*) into devuel from clientes where apell like ' apelli & %'
Este tipo de cosas


Si apelli es una columna, hay algo mal en la composición de la expresión.
apelli es una valor que le paso a la function, voy a poner el código completo

CREATE OR REPLACE FUNCTION cont_reg(apelli character varying)
  RETURNS integer AS
$BODY$

DECLARE
  devuel integer;
BEGIN
   if apelli is not null THEN   
select count(*) into devuel from pacientes where apell like '" || apelli || "%';
end if;                 

        if found then
                return devuel;
        else
                return 0;       
        end if;
END;

$BODY$
  LANGUAGE 'plpgsql' VOLATILE
  COST 100;
ALTER FUNCTION cont_reg(character varying) OWNER TO postgres;

Podrías mostar el registro que supuestamente te debería devolver?

--
TIP 6: �Has buscado en los archivos de nuestra lista de correo?
              http://archives.postgresql.org/pgsql-es-ayuda

Responder a