I just wrote a FUNCTION to return XML from a web service. As the text can go over 32,767 characters, i figured a CLOB was the way to go:
FUNCTION Get_XML(I_URL VARCHAR2)
RETURN XMLTYPE
AS
Page CLOB;
Response UTL_HTTP.HTML_PIECES;
BEGIN
Response := UTL_HTTP.REQUEST_PIECES(I_URL);
-- UTL_HTTP.REQUEST_PIECES returns 2000 byte chunks.
FOR Chunk IN 1..Response.Count
LOOP
Page := Page || Response(Chunk);
END LOOP;
RETURN XMLTYPE(Page);
END Get_XML;
My question is, is about the best way to concatenate the pieces. Is
Page := Page || Piece(Counter);
good, or should i be using DBMS_LOB.APPEND or similar?