0
declare
n_docid number;
n_orgid number;
n_docstateid number;
n_docstateversion number;
n_doctypeid number;
n_count number;
begin
for I in (select DOCID from DC_EXP_BO where INF_DATEDOCUMENT > '01.01.17' and
INF_DATEDOCUMENT < '31.12.17')
loop
begin
select DOCID, DOCSTATEID, DOCTYPEID, DOCSTATE_VERSION into
n_docid, n_docstateid, n_doctypeid, n_docstateversion from DOC
where DOCID = I.DOCID;
select ORGID into n_orgid from ORG
where systemname = (select distinct RB_CODEGRBS from DC_EXP_BO where DOCID = n_docid);
select count(*) into n_count from ROUTECONTEXT
where DOCID = n_docid and ORGID = n_orgid;
if (n_count = 0) then
insert into ROUTECONTEXT
(ROUTECONTEXTID, VERSION, DOCID, LOCALDOCSTATEID, OWNERID, LASTPRINTDATE, PRINTED, RECEIVED, ORGID, ARCHIVE, EXPORTSTATUS, DOCTYPEID, DOCSTATEID, DOCSTATE_VERSION, DELETED)
values
(sq_routeContext.NEXTVAL, 0, n_docid, n_docstateid, null, null, 0, 0, n_orgid, 0, 'NOT_EXPORTED', n_doctypeid, n_docstateid, n_docstateversion, 0);
end if;
exception
when no_data_found then
continue;
end;
end loop;
end;
/
我們爲生產寫了datafix。還有一個問題。 對於語句select可以返回大約100萬個ID。有沒有可能優化這個查詢?有沒有辦法優化這個查詢?
它工作!我不能爲你的業力加上+,因爲沒有足夠的聲望。 –
你問了這個問題,你可以對自己的問題進行投票並接受答案。 – APC
@APC:不錯的方法! –