比如我现在有两张表:
chnl_self_trade@dhcc 和 pos_points
我想在每天晚上6:00执行插入语句insert into pos_points select distinct(ac_no),'' from chnl_self_trade@dhcc where ac_no is not null表chnl_self_trade@dhcc中还有一个字段tx_date,记录的是交易日期,我想在插入的时候限制时间是从前天到昨天。这个存储过程怎么写啊,大家帮帮我啊
chnl_self_trade@dhcc 和 pos_points
我想在每天晚上6:00执行插入语句insert into pos_points select distinct(ac_no),'' from chnl_self_trade@dhcc where ac_no is not null表chnl_self_trade@dhcc中还有一个字段tx_date,记录的是交易日期,我想在插入的时候限制时间是从前天到昨天。这个存储过程怎么写啊,大家帮帮我啊
is
begin
insert into pos_points
select distinct(ac_no),''
from chnl_self_trade@dhcc
where ac_no is not null
and tx_date between trunc(sysdate-2) and trunc(sysdate-1);
end pr;然后使用dbms_jobs定时执行。
关于job的使用,参见:
http://blog.ixpub.net/html/17/12285417-403019.html
using (select distinct(ac_no) ac_no,''
from chnl_self_trade@dhcc
where ac_no is not null
and tx_date between trunc(sysdate-2) and trunc(sysdate-1)) t
on a.ac_no = t.ac_no
when not matched then
insert(a.c1) values(t.ac_no);
using (select distinct(ac_no),''
from chnl_self_trade@dhcc
where ac_no is not null
and to_date(tx_date,'yyyymmdd') between trunc(sysdate-10) and trunc(sysdate-1)) t
on (a.ac_no = t.ac_no)
when not matched then
insert(a.ac_no)
values(t.ac_no);
大哥,我按你的思路改后,报missing keyword 的错,您帮我看一下是哪错了啊?
注意加上列别名
using (select distinct(ac_no) ac_no,''
from chnl_self_trade@dhcc
where ac_no is not null
and to_date(tx_date,'yyyymmdd') between trunc(sysdate-10) and trunc(sysdate-1)) t
on (a.ac_no = t.ac_no)
when not matched then
insert(a.ac_no)
values(t.ac_no);
大哥,我加上了列的别名后,还是报错missing keyword,这条语句到底错在哪了呢,各位牛人大哥帮我写出一条可以执行的语句好吗,谢谢大家了
select distinct(ac_no) ac_no,''
from chnl_self_trade@dhcc
where ac_no is not null
and to_date(tx_date,'yyyymmdd') between trunc(sysdate-10) and trunc(sysdate-1)
可以出来结果,唯一可能错的地方就是merge语句了,大家帮我看看是哪错了啊。谢谢大家了
using (select distinct(ac_no) ac_no,''
from chnl_self_trade@dhcc
where ac_no is not null
and to_date(tx_date,'yyyymmdd') between trunc(sysdate-10) and trunc(sysdate-1)) t
on (a.ac_no = t.ac_no)
when matched then
update set a.col2 = ' '
when not matched then
insert(a.ac_no)
values(t.ac_no);