I\'m trying to perform a SELECT
with an IN
clause and I would like to be able to have the results returned in the same order as the elements in my list
Insert the values into a temporary table and join your select to that.
You can then do a natural order on your temporary table column.
CREATE GLOBAL TEMPORARY TABLE sort_table (
value VARCHAR2(100),
sort_order NUMBER
) ON COMMIT DELETE ROWS;
INSERT INTO sort_table VALUES ('B123',1);
INSERT INTO sort_table VALUES ('B483',2);
... etc. ...
select * from mytable
inner join sort_table
on mytable.mycolumn = sort_table.value
order by sort_table.sort_order;
To clear the temporary table, just COMMIT
.