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
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.