나는 테이블의 행을 업데이 트하는 기능을 가지고, 업데이 트가 가장 낮은 생성 날짜를 선택하고 거기에 각각의 청구 날짜를 비교하고, 거기에 만든 날짜를 가장 생성 날짜 이 선택 항목을 기반으로 시작 날짜를 업데이트하려고합니다.업데이트 쿼리 오라클 오랜 시간이 걸립니다
CREATE OR REPLACE FUNCTION OriginatedDate_update(total in Number)
RETURN VARCHAR2
IS
intialCount Number(10);
temp Number(10);
count1 Number(10);
BEGIN
SELECT COUNT(DISTINCT(p2.created_date)) INTO temp FROM discrepancy_grid_info p2 where billing_date is not null;
intialCount :=1;
temp :=temp+1;
WHILE intialCount < temp loop
update (SELECT * FROM discrepancy_grid_info p1 WHERE (intialCount-1) = (SELECT COUNT(DISTINCT(p2.created_date)) FROM discrepancy_grid_info p2 WHERE p2.created_date < p1.created_date) and billing_date is not null) f
set f.ORIGINATED_DATE=(SELECT MAX(p.ORIGINATED_DATE) FROM DISCREPANCY_GRID_INFO p where p.PRIM_ID=f.PRIM_ID AND p.PLAN_NAME=f.PLAN_NAME and p.PROCESS_INSTANCE_ID IN (select process_instance_id from audit_process where client_vendor_id in (select id from client_vendor where vendor_id=(select vendor_id from client_vendor where id=(select client_vendor_id from audit_process where process_instance_id=f.process_instance_id)) and client_id=(select client_id from client_vendor where id=(select client_vendor_id from audit_process where process_instance_id=f.process_instance_id))))
and p.billing_date between add_months(trunc(f.billing_date,'mm'),-1) and last_day(add_months(trunc(f.billing_date,'mm'),-1)) and p.billing_date is not null and p.created_date < f.created_date group by p.PRIM_ID,p.PLAN_NAME)
where f.billing_date is not null;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT);
count1 :=count1+SQL%ROWCOUNT;
intialCount :=intialCount+1;
end loop;
RETURN count1;
END;
작업하려는 항목과 관련된 DBMS에만 태그를 붙여야합니다. 여기에 더 자세한 정보가 필요합니다. 실제로 게시 된 것처럼 실제로 질문을하지 않았습니다. –
코드를 보여주십시오 .. – scaisEdge
코드가 아래에 있습니다, 내가 오버플로 스택에 새로 왔습니다 실수로 대답에 게시 – mktl