 SELECT o.obj_code as profile, o.obj_desc as profiledesc, o.obj_org as organization from r5objects o, r5userorganization u
 where  obj_obrtype= 'I'
 AND obj_code <> '*'
 AND o.obj_org = u.uog_org
 AND COALESCE( o.obj_notused, '-' ) <> '+'
 AND u.uog_user =<parameter.r5user>
 AND ( u.uog_common = '+' or u.uog_org = <control.org> )
 AND (<param.bypassdeptsecurity> = 'true'
      OR (<parameter.deptsec> ='OFF'
      OR (obj_mrc IN( SELECT dse_mrc FROM r5departmentsecurity WHERE dse_user =<parameter.r5user> AND dse_mrc = obj_mrc AND coalesce(dse_readonly, '-') = '-'))))