
本文共 3677 字,大约阅读时间需要 12 分钟。
���������������������������������������������
������������������������������������������������������������������������������������������������������������������������������Oracle������������Job���������������Unix���������crontab������������������������������������������������������������������������������
������������Oracle������������Job������������
1. Job���������
������Job������������������������������������������������������������������PLSQL������Job������������
begin sys.dbms_job.submit( job => :job, what => 'declare vo_errcode varchar2(200); vo_errmsg varchar2(200); begin staff_test_1(vo_errcode, vo_errmsg); end', next_date => to_date('28-12-2012 11:06:00', 'dd-mm-yyyy hh24:mi:ss'), interval => 'sysdate + 3000' ); commit;end;
������Job���������������������2012���12���28��� 11:06:00���������staff_test_1
������������������3000������������������
2. ������������
������������Job���������PLSQL������������������������������������������������
create or replace procedure staff_test_1( vo_errcode out varchar2, vo_errmsg out varchar2) isbegin insert into tp_staff_info_interface_1 values ( STAFF_ID, SERIAL, BRANCH_SERIAL, ... ) select ... from V_STAFF_JS_TEMP@to_jsappt_xsqd; commit; vo_errcode := '0'; vo_errmsg := 'ok'; exception when others then rollbtck; vo_errcode := SQLCODE; vo_errmsg := substr/sqlerrm(1, 255);end staff_test_1;
3. ���������������Job
������������SQL Plus���PLSQL���������������������������Job���������������������������������������������������������
������Unix������ crontab ������
���Unix/Linux������������crontab������������������������������������������������������crontab���������������������������
1. Shell������������
������������������������������������Shell������������Oracle���������������������������������
#!/bin/shDB_USER=DB_USERDB_PASS=DB_PASSDB_NAME=ORACLE# ������������������month=$1priority=$2# ���������������sqlplus -s "$DB_USER/$DB_PASS@$DB_NAME" << EOFset echo offset heading off declare vi_month varchar2(10); vi_priority number; vo_return number; vo_message varchar2(255);begin p_get_data_ctr('$month', $priority, :vo_return, :vo_message); disconnect; exit;EOF
������������������������������������������������������������������������Oracle������������������PLSQL������p_get_data_ctr
������������������������������������
2. ������������
���������p_get_data_ctr
������������������
create or replace procedure p_get_data_ctr( vi_month in varchar2, vi_priority in number, vo_return out number, vo_message out varchar2) isbegin -- ��������������������� vo_return := 0; vo_message := 'OK!'; -- ������������������ vv_return number; vv_message varchar2(255); -- ������������������ begin -- database logic here exception when others then rollbtck; vv_return := SQLCODE; vv_message := substr(sqlerrm, 1, 255); end; -- ������������������ vo_return := vv_return; vo_message := vv_message;end p_get_data_ctr;
3. ��������������� crontab
������������������crontab���������������������������������crontab
������������������������������������������������
crontab -e "@bash /path/to/your/script.sh"
������������@*/5 * * * *
���������5���������������
4. ������������
- ������������������������������������������tnsnames.ora������������������������������������tns���
- ���������������������Shell������������������������������������������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
