select 
o.obj_code as assetid,
o.obj_org as assetorganization,
o.obj_desc as assetdescription,
o.obj_bin as bincode,
IFNULL(o.obj_lot, '*') as lotcode
FROM r5objects o
 WHERE o.obj_part = <part_code> AND o.obj_part_org = <part_org> 
 AND o.obj_obrtype = 'A' 
 AND (o.obj_bin=<bin_code> or <bin_code> = '' or <bin_code> is null)
 AND ( ( o.obj_rstatus IN ( 'B','C' ) AND o.obj_store = <store_code> ) OR   
   ( o.obj_rstatus = 'T' AND obj_store IS NULL ) )
