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!

concating many strings - Java-Class StringBuilder equivalent?

TobiPAug 22 2012 — edited Aug 22 2012
Hi folks!

I am still quite new to pl/sql, so I would like to ask you for a better solution to my task, than my current one: (Havn't found anything appropriate yet after searching.)

From a select-statement in a for-loop I am generating html-code (for APEX) for a navigation-list.
So now I could do it like the following:
declare html_string varchar2(32767);
begin
   for i in (select fieldA from tableA)
   loop
      html_string := html_string || 'some html literals' || i.fieldA || 'more html literals';
   end loop:
return html_string;
end;
Now I know from Java and C# that this kind of string concatation creates a hugh overhead, hence you use the datatype StringBuilder, which sort of works like a dynamic array-pointer and far more performance effective.
I have thought about a cursor type, but I think this is not really the solution, because in the end I'd have to convert the entire cursor into a varchar2 - is this possible?

Is there a better way in pl/sql than my above example?

Thanks and greets,
tobi
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 19 2012
Added on Aug 22 2012
4 comments
490 views