필자는 PL/SQL에서 콜렉션을 가진 초보자이며, BULK COLLECT
및 FORALL
을 다중 테이블 레코드의 테이블로 사용하려고합니다. 루프를 반복하는 방법은 무엇입니까?이 여러 열의 테이블을 반복하는 방법은 무엇입니까?
다른 구문 옵션을 시도했지만 모두 실패했습니다. 복수 열에 대한 온라인 참조를 찾을 수 없습니다. 단일 열으로 예제를 찾을 수 있습니다.
--Here are my declarations. Note that there is more than one column in the record.
--The examples I could find online only use one column:
type mytable_rec is record
(
mytable_col1 mytable.mytable_col1%type,
mytable_col2 mytable.mytable_col2%type
);
type mytable_tab is table of mytable_rec;
l_mytable mytable_tab ;
--I've already loaded my query into l_mytable using bulk collect.
--Skipping it for readability
forall i in 1 .. l_mytable.count loop --The procedure won't compile
--because of this line
update mytable set
mytable.mytable_col1 = i.mytable_col1,
mytable.mytable_col2 = i.mytable_col2
where 1 = 1; --some condition goes here
end loop;
중 하나가 작동하지 않습니다 다음을 시도 :
forall i in l_mytable.first .. l_mytable.last loop --The procedure won't compile
--because of this line
update mytable set
mytable.mytable_col1 = i.mytable_col1,
mytable.mytable_col2 = i.mytable_col2
where 1 = 1; --some condition goes here
end loop;
감사합니다!/:
에서 더 많은 정보를 찾을 수 below.please 시도 /www.oracle.com/technetwork/issue-archive/2012/12-sep/o52plsql-1709862.html) –
@smn_onrocks 답장을 보내 주셔서 감사합니다. 불행히도이 예제는 또한 단일 열을 사용합니다. 내 테이블이 여러 열을 포함하는 레코드의 테이블 인 경우이를 통해 반복 할 수 있습니까? – Zesty