I’m an experienced programmer, but relatively new to SQL. We’re using Oracle 10 and 11. I have a system in place using SQL that combines actual rows with virtual rows (e.g. “SELECT 1 from DUAL”) doing unions and intersects as needed, which all seems to work.
My problem is that I need to combine this system which is expecting rows of data, with new data that will have the data in (let’s say for simplification) comma delimited strings.
So I think what I need is a way to convert a string like: “5,6,7,8” into 4 rows with one column each, with “5” in the first row, “6” in the second, etc. In other languages, I’d do a “Split” with comma as the delimiter. Of course, the data won’t always have 4 entries.
There’s a second question, but I’ll ask it separately. But I suspect it will simplify things, if possible, if the solution to the above could be used as a table in another SQL statement (i.e., to work with my existing system). Thanks for any help.
You should really extract that comma separated string into an outside program in any language, split it up, bulk-load it into a temp table, and use that temp table in your queries.
If you absolutely HAVE to do it in SQL, this article shows you how to do so:
http://www.oracle.com/technology/oramag/code/tips2007/070907.html