我有这个查询
select devlocview.ENTERPRISENAME
FROM AlarmDeviceView alrmDevView
INNER JOIN devicelocationview devLocView
ON devlocview.oid=alrmdevview.deviceoid
LEFT OUTER JOIN DEVICEGROUPVIEW devGrpView
ON devlocview.oid=devgrpview.deviceoid
LEFT OUTER JOIN RackCapacityView rackCapView
ON devlocview.RACKID=rackCapView.oid
WHERE
(
alrmdevview.createddate = ( select max(alview.createddate)
from alarmdeviceview alview
WHERE alview.alarmoid=alrmdevview.alarmoid)
or alrmdevview.createddate IS NULL
)
AND devlocview.ENTERPRISENAME='Enterprise1'
AND devlocview.buildingname in (
CASE
WHEN $p{building} IS not NULL THEN $p{building}
WHEN $p{building} IS NULL THEN (select buildingname from cdmr.devicelocationview)
END
)
在这里,这部分"select buildingname from cdmr.devicelocationview"
返回多行,因此我得到
异常为 01427. 00000 - “单行子查询返回多于一行”
根据要求,我想分配多个建筑物时$p{building} is null