SQL string manipulation to return multiple rows

Posted by Andy Jacobs on Stack Overflow See other posts from Stack Overflow or by Andy Jacobs
Published on 2010-05-07T02:06:22Z Indexed on 2010/05/07 2:08 UTC
Read the original article Hit count: 259

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about sql

Related posts about oracle11g