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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Displaying a BLOB image in an APEX Report

MaguzziMar 11 2015 — edited Mar 13 2015

Hi,

I have a BLOB column in a table that stores an image that I'd like to display in a report.

The table definition for the table (MAG_IMAGES) that I store the BLOB in is :

CREATE TABLE "MAG_IMAGES"

( "MAG_IMAGE_ID" NUMBER,

"IMAGE_NAME" VARCHAR2(200),

"CONTENT" BLOB,

"MIME_TYPE" VARCHAR2(1000),

"DOC_SIZE" NUMBER,

"CONTENT_TYPE" VARCHAR2(1000),

"DISPLAY_AREA" VARCHAR2(20),

"LAST_UPDATE_DATE" TIMESTAMP (6),

CONSTRAINT "MAG_IMAGES_PK" PRIMARY KEY ("MAG_IMAGE_ID") ENABLE

)

/

This is the Vendor_Group Table where I store the Image_Id.

CREATE TABLE "VENDOR_GROUP"

( "VENDOR_GROUP_ID" NUMBER,

"VENDOR_GROUP_NAME" VARCHAR2(100),

"IMAGE_ID" NUMBER

CONSTRAINT "VENDOR_GROUP_PK" PRIMARY KEY ("VENDOR_GROUP_ID") ENABLE

)

/

I created the following procedure IMAGE_DISPLAY which I sourced from a previous forum discussion.

create or replace PROCEDURE image_display( p_image_id IN NUMBER)

AS

   l\_mime        VARCHAR2 (255);

   l\_length      NUMBER;

   l\_file\_name   VARCHAR2 (2000);

   l\_content       BLOB;

BEGIN    

         SELECT mime\_type, content, DBMS\_LOB.getlength(content)

         INTO l\_mime, l\_content, l\_length

         FROM mag\_images

         WHERE mag\_image\_id = p\_image\_id;   

   OWA\_UTIL.mime\_header (NVL (l\_mime, 'application/octet'), FALSE);

   HTP.p ('Content-length: ' || l\_length);

   OWA\_UTIL.http\_header\_close;

   WPG\_DOCLOAD.download\_file (l\_content);

EXCEPTION

 WHEN OTHERS THEN RAISE;

END image_display;

I then create an APEX Report Region with the following source :

select a.group_product_list,

'<img src="image_display?p_image_id='||NVL(a.image_id,0)|| '" height="'|| 100|| '" />' photo

from vendor_group a, mag_images b

where image_id = b.mag_image_id(+)

and mag_vendor_id = 2;

The Image does not display, but looks like this below. I have set the column attribute to "Standard Report Column".

BLOB_Report.png

Can anyone please tell me what I am doing wrong?

Thanking you in advance

Dominic

This post has been answered by fac586 on Mar 12 2015
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 10 2015
Added on Mar 11 2015
25 comments
13,201 views