比如:
SELECT * FROM table1 WHERE ttime >= to_date('2011-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND :shegnxiao = 1shegnxiao是外部的一个变量,就是说当shegnxiao为1时ttime >= to_date('2011-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') 才生效。不过现在这样写不行因为后面还有其它判断条件
该怎么写请赐教~~~~
SELECT * FROM table1 WHERE ttime >= to_date('2011-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND :shegnxiao = 1shegnxiao是外部的一个变量,就是说当shegnxiao为1时ttime >= to_date('2011-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') 才生效。不过现在这样写不行因为后面还有其它判断条件
该怎么写请赐教~~~~
or ttime >= to_date('2011-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') )
if :shegnxiao=1 then
SELECT * FROM table1
WHERE ttime >= to_date('2011-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
else null
end if;
--
SELECT * FROM table1
WHERE
decode(:shegnxiao,
1,ttime >= to_date('2011-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
null
)