select 
obj_code as equipmentcode,
obj_desc as equipmentdesc,
o.obj_org as equiporganization
FROM  R5USERORGANIZATION u, R5OBJECTS o WHERE COALESCE(o.obj_notused, '-') <> '+' AND o.obj_obrtype = <param.objectrtype> 
AND u.uog_user =<parameter.r5user> AND
u.uog_org =  o.obj_org AND (u.uog_org = <param.objectorg>
OR EXISTS (SELECT 1 FROM r5organization WHERE 
org_code = <param.objectorg> AND org_common = '+')) 
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, '-') = '-'))))  
AND o.obj_code ||'#' ||o.obj_org <> COALESCE(<param.objectcode>,'#')+'#'+<param.objectorg>
AND (o.obj_code+'#'+o.obj_org) 
NOT IN (SELECT stc_child+'#'+stc_child_org FROM R5STRUCTURES where stc_parent = <param.objectcode> and stc_parent_org = <param.objectorg>) 
