You do not need to split the list into separate terms.
You can use LIKE
and surround the list and the matching values with the list delimiter:
SELECT *
FROM students
WHERE ',' || :yourList || ',' LIKE '%,' || room_number || ',%';
Which for your (hard-coded) values would be:
SELECT *
FROM students
WHERE ',1234,5678,' LIKE '%,' || room_number || ',%';
If you have the values stored in another table then you can JOIN
based on LIKE
:
SELECT s.*
FROM students s
INNER JOIN other_table o
ON (',' || o.room_list || ',' LIKE '%,' || s.room_number || ',%');
Which, for the sample data:
CREATE TABLE students (id, room_number) AS
SELECT 1, '1234' FROM DUAL UNION ALL
SELECT 2, '5678' FROM DUAL UNION ALL
SELECT 3, '1234,5678' FROM DUAL UNION ALL
SELECT 4, '9999' FROM DUAL;
CREATE TABLE other_table (room_list) AS
SELECT '1234,5678' FROM DUAL;
Outputs:
ID |
ROOM_NUMBER |
1 |
1234 |
2 |
5678 |
3 |
1234,5678 |
db<>fiddle here