Subject Selecting arbitrary records in an arbitrary order
Author Caroline Beltran

I hope that someone can advise how I can efficiently arbitrarily select data from a table.  I am provided with a list of IDs to display, for example:


Employee ID Numbers: 1032, 624, and 2841.


This would be the output (in the same order as the list above):


Employee ID FName LName

------------------  --------- ----------

1032             Frank  Burns

624               Jill      Applegate

2841             Angie  Cullens


The easiest and most obvious way to get this output is by using the SELECT statement 3 times:


SELECT id, fname, lname FROM employees WHERE id = 1032

SELECT id, fname, lname FROM employees WHERE id = 624

SELECT id, fname, lname FROM employees WHERE id = 2841


Please keep in mind that there is no criteria other than the ID and order provided in the list above.


Although this works, I would like to find the most efficient way to do this.  My first though was to create a temporary table where I insert the 3 IDs and link them to the Employees table but that looks even less efficient.


What came to mind next was a STORED PROCEDURE. 


What I would like to know is if it is possible to pass a variable amount of IDs and have the procedure parse each id and return the output as shown above? 


If so, would this be the most efficient way to have Firebird fulfill this requirement?


Thank you