想知道您是否可以帮助我解决一个问题。有人告诉我编写一个函数或匿名块,直到将项目放在表中之前,该函数或匿名块将一直运行/该程序应每5秒检查一次条目。它应该输出一条消息,通知您已进行检查的事实。找到该条目后,它将通知您找到了该条目,请删除该条目,然后退出。
我已经尝试了很长时间了,但是没有运气。
任何帮助将不胜感激。
谢谢你。
您必须使用while循环,并且可以通过调用dbms_lock.sleep(5)来控制5秒。
我没有访问Oracle DB的权限,但这是有关它如何工作的一般概念(MySQL)
create table tt_mess_around (`id` INT, `name` VARCHAR(50));
delimiter \\
create procedure watcher ()
BEGIN
declare foundInsert INT default 0;
while foundInsert = 0 do
select id from tt_mess_around limit 1 into foundInsert;
if (foundInsert = 0) then
select 'sleeping for 5 seconds' from dual;
do sleep(5);
end if;
end while;
delete from tt_mess_around where id = foundInsert;
select 'just deleted record' from dual;
END
\\
delimiter ;
call watcher;
insert into tt_mess_around
select 1, 'Arianna' from dual;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句