Skip to Main Content

APEX

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!

Splitting up text into chunks (no split words)

622829May 14 2008 — edited May 14 2008
I'm trying to figure out the best way to split up a body of text (say maybe 400-500 characters long) into 130 character-sized chunks with no words being split. I figured how to do this for the first chunk, but am having problems figuring out how to keep repeating it. Here's the code I have so far that calculates this properly for the first chunk:

declare
inc number := -1;
tmp_body nvarchar2(2000);

begin

tmp_body := 'blahblahblah...';

tmp_body := substr(tmp_body, 1, 130);

LOOP
if (substr(tmp_body, inc, 1) = ' ') then
exit;
end if;

inc := inc - 1;
END LOOP;

tmp_body := substr(tmp_body, 1, 130+inc);

end;


I know I need to substitute variables for the values of 1 and 130, right? Seems like this could get complicated very quickly unless I'm missing something.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 11 2008
Added on May 14 2008
2 comments
560 views