SELECT OBJ_CODE equipment,
       OBJ_DESC description,
       OBJ_ORG equipmentorg,
       CGO_EVENT surveywo,
       CGO_CAMPAIGN campaign,
       CGO_CAMPAIGN_ORG campaignorg
FROM R5OBJECTS o, R5CAMPAIGNOBJECTS, r5userorganization u
WHERE o.OBJ_CODE = CGO_OBJECT AND
      CGO_STATUS = 'NE' AND
      (CGO_EVENT IS NULL OR CGO_EVENT = '')
      AND CGO_CAMPAIGN=<param.campaign>
      and IFNULL(o.obj_notused, '-') <> '+'
      and o.obj_org = u.uog_org
      and u.uog_user = <parameter.r5user>
      AND (<parameter.bypassdeptsecurity> = 'true' OR (<parameter.deptsec> ='OFF' OR
      (o.obj_mrc IN( SELECT dse_mrc FROM r5departmentsecurity WHERE dse_user =<parameter.r5user> AND dse_mrc = o.obj_mrc AND coalesce(dse_readonly, '-') = '-'))))
ORDER BY OBJ_CODE, OBJ_ORG
