select 
m.mrc_code as departmentcode,
m.mrc_org as departmentorganization,
m.mrc_desc as departmentdescription
from r5mrcs m, r5userorganization u where  
m.mrc_org = u.uog_org and u.uog_user = <parameter.r5user> and 
( u.uog_common = '+' OR u.uog_org = <control.org> ) and coalesce(mrc_notused, '-') <> '+' 
AND (<param.bypassdeptsecurity> = 'true' OR (<parameter.deptsec> ='OFF' OR  
(mrc_code IN( SELECT dse_mrc FROM r5departmentsecurity WHERE dse_user = <parameter.r5user> 
AND dse_mrc = mrc_code AND coalesce(dse_readonly, '-') = '-')))) 
