Need help to pass a comma separated string into a stored procedure
565755Mar 7 2007 — edited Mar 7 2007Hello!
I'm in troubles guys... I'm responsible for MS SQL Server 2000 database migration to ORACLE 9i. I have a bunch of stored procedures that really drive me crazy. Some of those T-SQL statements don't make any sense even in SQL Server, but the problem is that MS SQL is very "forgivable" - it does a lot of implicit conversions and assumptions which gives you an opportunity to write a poor-quality code. It's a real nightmare.
To make it worse - I can't change application calls to those stored procedures - the number of input and output params should remain the same. The idea is just to change the underlying database engine and keep the application intact. In theory sounds great, but....
OK. There's one of those stored procedures:
CREATE PROC spLocations_sel
@LocationIDs varchar
AS
SELECT * FROM Locations
WHERE LocationID IN (@LocationIDs)
application sends @LocationIDs as a comma-separated string of values, e.g. '10,11,12'
MS SQL allows that, but as you can imagine "WHERE LocationID IN (@LocationIDs)"
doesn't work in ORACLE - first of all LocationID table column's type is INT and @LocationIDs is a varchar, and so on.....
As I said - stored proc should accept that comma-separated list of values. I can't change that.
Any idea?
Thanks a lot.