XML BLOB Examples

 BLOB Examples

Can’t generate xml data for CLOB more than 40 kb in report builder. 
BLOB Images are supported in XML Publisher 5.6.2 or later. 
Encode BLOB to CLOB use this following function:
CREATE FUNCTION getbase64( p_source BLOB )
RETURN CLOB
IS
v_result CLOB;
BEGIN
DBMS_LOB.createtemporary(lob_loc => v_result, CACHE => FALSE, dur => 0);
Wf_Mail_Util.EncodeBLOB ( p_source, v_result);
RETURN ( v_result );
END getbase64; 
To show BLOB Images use the following code:
<fo:instream-foreign-object content-type=”image/jpg”><xsl:value-of select=”.//IMAGE_”/></fo:instream-foreign-object> 
<fo:instream-foreign-object content-type="image/jpg" xdofo:alt="An Image" ><xsl:value-of select=".//AD_COMPOSITE"/></fo:instream-foreign-object>

XML Publisher supports in general right now only JPG, GIF and PNG. 


CREATE or replace FUNCTION PFC_SHOW_IMAGE(P_PERSON_ID NUMBER)

RETURN CLOB
IS
v_result CLOB;
l_blob blob;
sizeb  PLS_INTEGER := 4080;
buffer RAW(4080);
offset PLS_INTEGER DEFAULT 1;
begin
BEGIN
SELECT  PerImageEO.IMAGE 
into l_blob
  FROM   PER_IMAGES PerImageEO
 WHERE   PerImageEO.PARENT_ID = P_PERSON_ID
 and PerImageEO.TABLE_NAME = 'PER_PEOPLE_F';
exception when others then 
null;
end;
DBMS_LOB.createtemporary(lob_loc => v_result, CACHE => FALSE, dur => dbms_lob.CALL);
--Wf_Mail_Util.EncodeBLOB ( l_blob, v_result);

LOOP
      BEGIN
        dbms_lob.READ(l_blob, sizeb, offset, buffer);
      EXCEPTION
        WHEN no_data_found THEN
          EXIT;
      END;
      offset := offset + sizeb;
      dbms_lob.append(v_result,
                      to_clob(utl_raw.cast_to_varchar2(utl_encode.base64_encode(buffer))));
    END LOOP;
RETURN ( v_result );

END PFC_SHOW_IMAGE;

0 comments:

Post a Comment