关于dbms_job
写了个事务处理
declare
v_jobnum binary_integer;
begin
dbms_job.submit(v_jobnum,'sgj1;',sysdate,'sysdate+(1/(24*60*60))');
dbms_output.enable;
dbms_output.put_line('your job number assigned is:'||v_jobnum);
dbms_job.run(v_jobnum);
end;
/
开始还能执行,我要修改procedure sgj1,所以先把改事物给remove了,可我又执行事物时,遇到下列错误.
SQL> @test.sql
declare
*
ERROR at line 1:
ORA-12011: execution of 1 jobs failed
ORA-06512: at "SYS.DBMS_IJOB", line 394
ORA-06512: at "SYS.DBMS_JOB", line 276
ORA-06512: at line 7
请各位高手帮帮忙!
问题点数:100、回复次数:13Top
1 楼shipatrioc(风吹雨打哗啦啦)回复于 2002-04-13 15:23:13 得分 0
ORA-06512: at line 7 is:
dbms_job.run(v_jobnum);
为什么不让我执行呢?
Top
2 楼KingSunSha(弱水三千)回复于 2002-04-13 15:31:11 得分 20
ORA-12011 execution of string jobs failed
Cause: Some kind of error was caught in DBMS_IJOB.RUN. One or more jobs which were due to be run produced errors which they could not handle.
Action: Look at the alert log for details on which jobs failed and why.
Top
3 楼shipatrioc(风吹雨打哗啦啦)回复于 2002-04-13 15:56:40 得分 0
我加了一个exception处理,没了该错误,估计结果不太对
我想问一下用dbms_job处理事物时,一般应注意些什么,
KingSunSha(弱水三千)先生.第一次用这东东,感觉还没
程序处理起来方便,比如错误提示,信息显示...,难道非的来一个
错误信息表记录它?Top
4 楼KingSunSha(弱水三千)回复于 2002-04-13 16:39:58 得分 0
在exception处理中输出错误代码和错误信息:
exception others then
dbms_out.put_line(to_char(sqlcode)|| ':' ||sqlerrm);
我基本上不用dbms_job来处理定时任务,我觉得用操作系统级的任务管理更方便,所以也不是很熟悉Top
5 楼jlandzpa(jlandzpa)回复于 2002-04-13 21:09:43 得分 30
unix的cron更稳定些!Top
6 楼ykliu1(river)回复于 2002-04-14 10:12:46 得分 10
dbms_job.submit(v_jobnum,'sgj1;',sysdate,'sysdate+(1/(24*60*60))');
dbms_output.enable;
dbms_output.put_line('your job number assigned is:'||v_jobnum);
dbms_job.run(v_jobnum);
根据你提供的代码,该JOB应该每1/(24*60*60)天(即每1秒钟)执行一次。开始执行的时间为SYSDATE即当时,即该JOB已经开始执行,由遇到RUN(执行),所以第七行出错:dbms_job.run(v_jobnum);
我想你可以去掉第七行,效果一样,即建立一个JOB。但让一个JOB每秒执行一次,太离谱了吧。Top
7 楼ykliu1(river)回复于 2002-04-14 10:13:52 得分 0
你的sgj1一秒钟能执行完吗?Top
8 楼hrb_qiuyb(晨钟暮鼓)回复于 2002-04-15 08:11:06 得分 20
你的Job写的没有问题,从你的报错信息上看是Top
9 楼hrb_qiuyb(晨钟暮鼓)回复于 2002-04-15 08:12:39 得分 0
没写完就提交了:接上
存储过程的错,把你的sgj1的内容贴出来吧.
Top
10 楼shipatrioc(风吹雨打哗啦啦)回复于 2002-04-16 13:44:50 得分 0
确实是存储过程的错,我加了一个exception就好了!谢谢各位
另外,jlandzpa说
unix的cron更稳定些!我还没
用过这玩艺,我先查些资料,另外,请 jlandzpa(做梦也想证明歌德巴赫猜想)
先生先谈谈,谢谢Top
11 楼flowerofwind(现实很残酷)回复于 2002-04-16 14:05:17 得分 20
crontab是unix定时执行任务的工具,;每个crontab文件包括一行共6项
+ The first field specifies the minute (0 to 59).
+ The second field specifies the hour (0 to 23).
+ The third field specifies the day of the month (1 to 31).
+ The fourth field specifies the month of the year (1 to 12).
+ The fifth field specifies the day of the week (0 to 6 for Sunday to
Saturday).
+ The sixth field specifies the shell command to be executed.
例如:
30 6 * * 1 /usr/bin/calendar
表示每个星期一六点半执行日立
Top
12 楼jlandzpa(jlandzpa)回复于 2002-04-16 14:22:14 得分 0
ok!
--关于unix的cron机制
利用unix的cron机制可以完成定时功能,稳定性比oracle的job好!
举例说明如下:
1. 在unix环境中用crontab -e编辑任务文件:
0,10,20,30 * * * * /usr/users/renwu_autojk
该任务表明:每天晚上12点0,10,20,30时运行任务:renwu_autojk
参数:* * * * *
意义如下:分钟,小时,天,月,星期
2. 编辑任务文件renwu_autojk的内容:
ORACLE_HOME=/usr/users/oracle8/app/oracle/product/8.0.6 --oracle home的路径
export ORACLE_HOME
ORACLE_SID=ora8 --oracle sid
export ORACLE_SID
ORACLE_TERM=vt100 --oracle的终端属性
export ORACLE_TERM
ORACLE_NLS=$ORACLE_HOME/ocommon/nls/admin/data --ORACLE_NLS路径
export ORACLE_NLS
NLS_LANG='AMERICAN_AMERICA.zhs16gbk' --字符集
export NLS_LANG
$ORACLE_HOME/bin/sqlplus scott/tiger @/usr/users/autojk
--调用sqlplus,进入scott用户,运行文件/usr/users/autojk.
3.autojk.sql文件的内容(可以是任何合法的sql语句)
exec p_main('1')
exit
这个例子表明运行过程p_main('1').
4.记着把文件的属性改为chmod 744 文件名
表明:文件的所有者对文件有读,写,执行的权限
文件的所有者同组的用户对文件只有读的权限
文件除此之外其他的用户对文件只有读的权限
Top
13 楼shipatrioc(风吹雨打哗啦啦)回复于 2002-04-16 14:40:55 得分 0
消化消化,回来给分Top




