将SQLSERVER存储过程改为ORACLE的存储过程

zyh9188 2006-12-28 10:10:16
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='整理'

请高手指招!
...全文
169 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
icedut 2006-12-28
  • 打赏
  • 举报
回复

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;
zyh9188 2006-12-28
  • 打赏
  • 举报
回复
给个完整的存储过程代码,好吗?
zyh9188 2006-12-28
  • 打赏
  • 举报
回复
感谢以上朋友的支持与帮助。这个存储过程的用途是经过40分钟后自动改变状态。
icedut 2006-12-28
  • 打赏
  • 举报
回复
老大客气了
我还得多像你学习呢
wiler 2006-12-28
  • 打赏
  • 举报
回复
好的,谢谢
icedut 2006-12-28
  • 打赏
  • 举报
回复
wiler(@_@) ( ) 信誉:100 Blog 2006-12-28 10:38:02 得分: 0


说得好,我理解错了,以为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

wiler 2006-12-28
  • 打赏
  • 举报
回复
说得好,我理解错了,以为datediff(Mi,js_txx.dktsj,getdate()>40)是天
是分钟吗?
icedut 2006-12-28
  • 打赏
  • 举报
回复

SELECT (SYSDATE-TO_DATE('2006-12-28 10:00','yyyy-mm-dd hh24:MI:ss'))*24*60
FROM dual

--
我这样做得到mi的差异,


icedut 2006-12-28
  • 打赏
  • 举报
回复
where trunc(sysdate-dktsj)>40


--这个不对 吧
返回的天数

where (SYSDATE-js_txx.dktsj)*24*60>40
wiler 2006-12-28
  • 打赏
  • 举报
回复
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 trunc(sysdate-dktsj)>40
and rowid=a.rowid
)
and js_txx.ctzt='整理';
commit;
end proc_js_txx_1;
/

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧