Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to split a text string based on a specific character?

Don07Jan 21 2019 — edited Jan 22 2019

Hello There,

I have a PL/SQL block which generates a concatenated string of sentences. The sentence is always prefixed with a special character '*'.

Below is the sample code/output showing the final concatenated string looks like. The Desire output which should show up as 3 rows. Is there a way to loop through the l_string  and split the string as shown in the desrire output. How can this be done?

1A: Sample code:

DECLARE

   l_string  VARCHAR2(4000);

BEGIN

     ...

     l_string := '*This is the 1st sentence*This is the second Sentence*Last code Line';

     dbms_output.put_line(l_string);

END;

1B: Sample Output:

*This is the 1st sentence*This is the second Sentence*Last code Line

2B: Desire output:

*This is the 1st sentence

*This is the second Sentence

*Last code Line

Look forward to hearing from you.

Regards,

Don

This post has been answered by Solomon Yakobson on Jan 21 2019
Jump to Answer
Comments
Post Details
Added on Jan 21 2019
5 comments
194 views