create procedure proc_js_txx_1
as
update js_txx
set js_txx.ctzt='空闲',
js_txx.dktsj=null
from js_txx
where datediff(Mi,js_txx.dktsj,getdate()>40)
and js_txx.ctzt='整理'请高手指招!
as
update js_txx
set js_txx.ctzt='空闲',
js_txx.dktsj=null
from js_txx
where datediff(Mi,js_txx.dktsj,getdate()>40)
and js_txx.ctzt='整理'请高手指招!
as
begin
update js_txx a
set js_txx.ctzt='空闲',
js_txx.dktsj=null
where exists (
select 1 from js_txx
where trunc(sysdate-dktsj)>40
and rowid=a.rowid
)
and js_txx.ctzt='整理';
commit;
end proc_js_txx_1;
/
--这个不对 吧
返回的天数where (SYSDATE-js_txx.dktsj)*24*60>40
SELECT (SYSDATE-TO_DATE('2006-12-28 10:00','yyyy-mm-dd hh24:MI:ss'))*24*60
FROM dual--
我这样做得到mi的差异,
是分钟吗?
说得好,我理解错了,以为datediff(Mi,js_txx.dktsj,getdate()>40)是天
是分钟吗?
----
看来你对sqlserver不太熟悉:)DATEDIFF
返回跨两个指定日期的日期和时间边界数。 语法
DATEDIFF ( datepart , startdate , enddate ) 参数
datepart是规定了应在日期的哪一部分计算差额的参数。下表列出了 Microsoft® SQL Server™ 识别的日期部分和缩写。日期部分 缩写
year yy, yyyy
quarter qq, q
Month mm, m
dayofyear dy, y
Day dd, d
Week wk, ww
Hour hh
minute mi, n
second ss, s
millisecond ms
create or replace procedure proc_js_txx_1
as
begin
update js_txx a
set js_txx.ctzt='空闲',
js_txx.dktsj=null
where exists (
select 1 from js_txx
where (SYSDATE-js_txx.dktsj)*24*60>40
and rowid=a.rowid
)
and js_txx.ctzt='整理';
commit;
end proc_js_txx_1;