Ver Mensaje Individual
  #42  
Antiguo 17-06-2011
Avatar de RONPABLO
[RONPABLO] RONPABLO is offline
Miembro Premium
 
Registrado: oct 2004
Posts: 1.514
Reputación: 21
RONPABLO Va por buen camino
Yo también hago mucho este tipo de consultas:

Código SQL [-]
select * from CLIENTES where (:APELLIDOS is null or APELLIDOS = :APELLIDOS) and            (:TELEFONO is null or TELEFONO = :TELEFONO)

Pero nunca las hago desde un Query directo debido a el error que comentan, siempre las he hecho desde un procedimiento almacenado y así nunca me ponen problemas...


Respecto a

Código SQL [-]
select * from tabla where cast(:id as integer) is not null and id = :id and tipo = 0  select * tabla where id = :id and tipomov = 0

Entiendo lo expresado por maeyanes ya que en un query (hasta donde entiendo) decir

Código SQL [-]
where campo = Null

no debe de retornar algún valor por la forma como se debe de tratar los nulos.


Y sigo sin entender y me gustaría saber para que se puede usar un query así:

Código SQL [-]
Select Campo1 from Tabla1   where :Clave is Null
Sin hacer algo como lo que muestra guillotmarc... Aun así en un sp debe de funcionar bien esa consulta.
__________________
"Como pasa el tiempo..... ayer se escribe sin H y hoy con H"
Responder Con Cita