有没有一个函数可以实现将SQL语句中用sysdate作为判断条件的时间解析出来,
例如select count(begintime)from faxtable where begintime <= sysdate - 5;
或 select count(begintime)from faxtable where begintime <= sysdate - 1/14;
或 select count(begintime)from faxtable where begintime <= sysdate - 0.2;
有没有一个Oracle的函数可以解析出<=后的时间是多少呢?
例如select count(begintime)from faxtable where begintime <= sysdate - 5;
或 select count(begintime)from faxtable where begintime <= sysdate - 1/14;
或 select count(begintime)from faxtable where begintime <= sysdate - 0.2;
有没有一个Oracle的函数可以解析出<=后的时间是多少呢?
比如
select count(begintime),sysdate - 5 from faxtable where begintime <= sysdate - 5;
select count(begintime),sysdate - 1/14 from faxtable where begintime <= sysdate - 1/14;
select count(begintime),sysdate - 0.2 from faxtable where begintime <= sysdate - 0.2;
关键是你想干什么,不一定非都要通过你想的方式来做。
这个需求对于Oracle函数来说太苛刻了,即使是java或者其他高级面向对象语言也不会提供这样功能的api.
只能通过自定义的函数来实现。
关键是你想干什么,不一定非都要通过你想的方式来做。]我的目的就是获取时间.[这个需求对于Oracle函数来说太苛刻了,即使是java或者其他高级面向对象语言也不会提供这样功能的api.
只能通过自定义的函数来实现。]我想也是的,只能自己写函数来实现了,只是对于复杂的SQL语句,我该怎样获取sysdate后面到底减的是多少呢
如果这个sysdate只是出现在where子句中,那么还好判断一些。where 里面要么后面跟着and/or,要么就是结束了。所以取sysdate后的and/or的位置,如果取不到,就是到末尾了 。然后对取到的sysdate到“and/or/末尾”这一部分取“=或>或<”之后的trim就可以了。
提示:自己写函数中获得具体时间建议考虑用本地动态SQL,其他的方法我没有想出来。
但是如果用trim取出的字符串是个分数,譬如1/14,该怎么求得结果呢