Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: like no funciona


  • From: suso <jlcubas(at)terra(dot)es>
  • To: Emanuel Calvo Franco <postgres(dot)arg(at)gmail(dot)com>
  • Cc: PostgreSQL <pgsql-es-ayuda(at)postgresql(dot)org>
  • Subject: Re: like no funciona
  • Date: Sat, 28 Nov 2009 14:28:01 +0000
  • Message-id: <4B113371.6050100@terra.es> <text/plain>

Hola Emanuel
2009/11/27 suso <jlcubas(at)terra(dot)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?




Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group