I have to split the declared string delimited by ; into rows as below. It works well if I declare the string and split it. Instead of declaring, I have to select this string from a table and parse it repeatedly. Each row can contain different number of strings.
What would be the best approach?? Should I loop through each row, parse them or is there a better way of doing it??
--Required output
status := off
status:= on
--QUERY
declare
myString varchar2(2000):='status := off; status:= on;';
begin
for r in
( select regexp_substr(myString,'[^;]+',1,level) element
from dual
connect by level <= length(regexp_replace(myString,'[^;]+')) + 1
)
loop
dbms_output.put_line(r.element);
end loop;
end;