因此,需oracle存储过程,存储过程中,部分代码如下:
点击(此处)折叠或打开
-
v_startdate := '2015-03-04 08:00:00'; --测试用
-
loop
-
--获取时间戳,5分钟后的时间戳,将同步的数据,分成小块进行同步
-
v_date_t := to_char(to_date(v_startdate, 'yyyy-MM-dd hh24:mi:ss') + 5/(24*60), 'yyyy-MM-dd hh24:mi:ss');
-
exit when to_date(v_date_t, 'yyyy-MM-dd hh24:mi:ss') > sysdate;
-
--根据台账历史表找出订购sp的工单数据
-
v_sql := '
-
insert into ti_jy_trade_t
-
select tb1.trade_id, tb1.trade_type_code, tb1.in_mode_code,
-
tb1.product_id, tb1.brand_code, tb1.user_id, tb1.cust_id,
-
tb1.net_type_code, tb1.serial_number, tb1.cust_name,
-
tb1.accept_date, tb1.finish_date,tb1.eparchy_code,
-
tb1.city_code,tb1.cancel_tag,tb1.remark
-
from ' || user_name || '.mytable' || v_dblink || ' tb1
-
where tb1.net_type_code in (''' || '10' || ''', ''' || '16' ||
-
''', ''' || '17' || ''', ''' || '33' || ''')
-
and tb1.cancel_tag = '''||'0'||'''
-
and tb1.subscribe_state = '''||'9'||'''
-
and tb1.next_deal_tag = '''||'0'||'''
-
and tb1.finish_date >= to_date(''' || v_startdate ||
-
''',''' || 'yyyy-MM-dd hh24:mi:ss' ||
-
''') and tb1.finish_date < to_date(''' || v_date_t ||
-
''',''' || 'yyyy-MM-dd hh24:mi:ss' || ''')
-
and exists
-
(select 1 from '||user_name||'.tf_b_trade_sp'||v_dblink||' tb2
-
where tb1.trade_id = tb2.trade_id
-
and tb2.sp_product_id = '''||v_sp_product_id||''')';
-
--dbms_output.put_line('start_date= '||v_startdate||', end_date='||v_date_t);
-
execute immediate v_sql;
-
commit;
-
v_startdate := v_date_t;
- end loop;