2010-12-01 3 views
0

을 선택하는 방법 cursor-, 직원 에서 을 isenrolled 여기서 isenrolled = 1 이제 원하는비교하고 내가 두 커서를 비교하고 내가</p> <p>예를 커서 c_stock_option이 선택 EMPID, 이름, 사회 보장 번호 (SSN) IS 그렇게 어떻게 독특한 발스을 retrun해야하는 경우 독특한 기록을

2 isenrolled = 여기서 커서 c_espp_option는 이름, 주민등록번호, 직원 에서 를 선택 EMPID isenrolled IS

커서 1에있는 두 번째 커서에서 모든 recs를 거부하려면 어떻게해야합니까?

답변

0

음 ..... 정의에 따라 isenrolled = 2 인 모든 행은 isenrolled = 1. 하지만 다른 결과 집합에서 행을 제외하는 방법에 대한 좀 더 일반적인 질문을하고 있다고 생각합니다. 이 경우

, 당신은 몇 가지 다른 방법이 걸릴 수 :

1)

CURSOR c_stock_option IS 
    Select empid, name, ssn, isenrolled from employee where isenrolled=1 
    MINUS 
    Select empid, name, ssn, isenrolled from employee where isenrolled=2 

2)

CURSOR c_stock_option IS 
    Select empid, name, ssn, isenrolled from employee 
    where isenrolled=1 
    and empid not in (
     Select empid, name, ssn, isenrolled from employee where isenrolled=2) 

3)

CURSOR c_stock_option IS 
    Select empid, name, ssn, isenrolled from employee e 
    where isenrolled=1 
    and not exists(
     Select 1 from employee where e.empid = employee.empid and isenrolled=2) 

을 어느 당신은 당신의 상황에 달려 있습니다. 데이터 모델, 색인 생성 등