You can combine them with a manual pivot:
select max(case when name = 'Cat' then id end),
max(case when name = 'Dog' then id end),
max(case when name = 'Mouse' then id end)
into varCat, varDog, varMouse
from mytable
where type = 'Object'
and name in ('Cat', 'Dog', 'Mouse');
Quick demo:
create table mytable (id number, type varchar2(10), name varchar2(10));
insert into mytable (id, type, name) values (1, 'Object', 'Mouse');
insert into mytable (id, type, name) values (2, 'Object', 'Cat');
insert into mytable (id, type, name) values (3, 'Object', 'Dog');
set serveroutput on
declare
varCat mytable.id%type;
varDog mytable.id%type;
varMouse mytable.id%type;
begin
select max(case when name = 'Cat' then id end),
max(case when name = 'Dog' then id end),
max(case when name = 'Mouse' then id end)
into varCat, varDog, varMouse
from mytable
where type = 'Object'
and name in ('Cat', 'Dog', 'Mouse');
dbms_output.put_line('varCat: ' || varCat);
dbms_output.put_line('varDog: ' || varDog);
dbms_output.put_line('varMouse: ' || varMouse);
end;
/
varCat: 2
varDog: 3
varMouse: 1
PL/SQL procedure successfully completed.
If the combination of type and name is not unique then your current code would error (too-many-rows); this would silent pick the highest ID.
If you're also getting IDs for other types where the name might be the same, you can include the type in the case expression too:
select max(case when type = 'Object' and name = 'Cat' then id end),
max(case when type = 'Object' and name = 'Dog' then id end),
max(case when type = 'Object' and name = 'Mouse' then id end)
-- , ... other combinations you want to get
into varCat, varDog, varMouse --, ... other variables
from mytable
where (type = 'Object' and name in ('Cat', 'Dog', 'Mouse'))
or ... ;
Type + Nameis unique. But there can be multipleCatswith different types and obviously multipleObjectswith different names.