여러 커서에서 하나씩 추가하여 사용자 지정 개체를 포함하는 중첩 테이블을 만들고 싶습니다. 하지만 나는 테이블에 중복 된 것을 원하지 않습니다. 이것을 어떻게 할 수 있습니까? 여기요소가없는 경우에만 중첩 테이블에 요소를 삽입 할 수 있습니까?
내가 테이블에 요소를 추가하는 방법입니다 : 이것은 단지 예이며,이 특별한 경우에 선택은 단 하나의 커서를하기 위해 변경 될 수 있습니다
create type recipient as object (firstname varchar2, lastname varchar2, email varchar2);
declare type recipients_list is table of recipient;
rec recipients_list := recipients_list();
cursor admins is
select firstname, lastname, email
from users
where profile_id = 1;
cursor operators is
select firstname, lastname, email
from users
where operator = 1;
-- an user may be both admin and operator
....
for to_email in admins
loop
rec.extend;
rec(rec.last) := recipient(to_email.firstname, to_email.lastname, to_email.email);
end loop;
for to_email in operators
loop
rec.extend;
rec(rec.last) := recipient(to_email.firstname, to_email.lastname, to_email.email);
end loop;
하는 것으로. 하지만 제 신청서에는 상황이 다릅니다. 감사!
감사 APC! 여러 개의 노동 조합을 가질 수 있습니까? 새로운 select를 추가하면'recs : = admins multiset union distinct operators multiset union distinct vips; '와 같이 쓸 수 있습니까? 고맙습니다! – radonys