select 
m.mrc_code as department,
m.mrc_desc as des_text
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 ='*' 
OR (mrc_code IN( SELECT dse_mrc FROM r5departmentsecurity 
WHERE dse_user =<parameter.r5user> AND dse_mrc = mrc_code 
AND coalesce(dse_readonly, '-') = '-'))))