select o.obj_desc as des_text,
    o.obj_org as locorganization,
    o.obj_code as parentlocation,
    CASE o.obj_safety WHEN '+' THEN -1 ELSE <param.safety> END as safety
    from  r5objects o , r5userorganization u
    where  o.obj_obrtype='L'
    and o.obj_org = u.uog_org  and u.uog_user = <parameter.r5user>  and ( u.uog_common = '+' or u.uog_org = <control.org> )  
    and IFNULL(o.obj_notused, '-') <> '+'  
    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, '-') = '-'))))





