plsqldeveloper - cursor- how to compare and select unique records -


if have compare 2 cursors , retrun unique vals how do that

example cursor c_stock_option select empid, name, ssn, isenrolled employee isenrolled=1

cursor c_espp_option select empid, name, ssn, isenrolled employee isenrolled=2

now want reject recs in second cursors in cursor 1 select, how do that

ummm.....by definition, of rows isenrolled=2 not overlap rows isenrolled=1. think you're asking more general question how exclude rows 1 result set in another.

if case, take few different approaches:

1)

cursor c_stock_option     select empid, name, ssn, isenrolled employee isenrolled=1    minus    select empid, name, ssn, isenrolled employee isenrolled=2 

2)

cursor c_stock_option     select empid, name, ssn, isenrolled employee     isenrolled=1      , empid not in (       select empid, name, ssn, isenrolled employee isenrolled=2) 

3)

cursor c_stock_option     select empid, name, ssn, isenrolled employee e    isenrolled=1      , not exists(       select 1 employee e.empid = employee.empid , isenrolled=2) 

which choose depends on situation, data model, indexing etc.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -