Friday, May 22, 2009

Using APEX_UTIL.GET_BLOB_FILE_SRC on a Public page

I had to show images on a public page. I've used my own procedure to do that, but when the build-in APEX procedure APEX_UTIL.GET_BLOB_FILE_SRC came available, I tend to use that. Last year I blogged about how to show an image on your page with that procedure.

So I already used this method for a while, but this time when I ran the page it didn't show my image. I was sure my code was right, because somewhere else in the application it worked just fine. The only difference was the working page is not a public page, but authentication is required.

It remembered me to a question we got last year on our training, why a picture didn't show up in somebodies APEX application. It was the same problem, the use of APEX_UTIL.GET_BLOB_FILE_SRC on a public page didn't work if it references an item on a page that requires authentication.

So here are the steps to let APEX_UTIL.GET_BLOB_FILE_SRC work on a public page.

1) In this example we are on a Public Page 6.
2) On that page I've an hidden item that looks like this:

3) My code to show the image looks like this: APEX_UTIL.GET_BLOB_FILE_SRC('P6_FILE_BLOB',

4) You would think the above is enough to let it work, but it isn't as we didn't tell from which table this image is coming from. So I had to create an after submit process that links to the right table. I 've a condition to Never on the process, so it never runs, but apparently the APEX_UTIL.GET_BLOB_FILE_SRC procedure looks at that to figure out from which table the image comes from.

That should be enough to show images on your Public Page using the APEX_UTIL.GET_BLOB_FILE_SRC procedure.


Oscar Gordillo said...

What code do you put in the application process?

barquet80 said...

Thanks it has been really useful but now the image appears but when i am on a report and click on the edit link im supposed to be sent to a form where all the data appears, including the image, but it doesnt, so when i make any change i am obligated to reenter the image why?

Unknown said...

Please, how it is possible to control the size of the blob column?

Dimitri Gielis said...

with dbms_lob.getlength you can verify the size of the blob

Greg J said...

Thanks for all the tips. It's hard to believe you need to create dummy processes to make this work. But considering the poor documentation of this feature kudos to you for figuring it out.

Arif Khadas said...

How can the same be implemented on page 0 (zero)? On page 0 Automatic Row Processing Process cannot be created.

Dimitri Gielis said...

You can create your own procedure that reads directly from the table (as you say, you can't use the arp)

Arif Khadas said...

Thanks for your reply Dimitri Gielis.

Instead of creating the Item and ARP Process on Page 0 I created it on Page 1 and then referenced this Page 1 Item in the call to GET_BLOB_FILE_SRC procedure and it worked fine.
But my actual aim is to display a BLOB image in a dynamic list, I am using APEX_UTIL.GET_BLOB_FILE_SRC ('P1_NAV_IMAGE', NAV_ID, NAV_COM_ID) in the select for the IMAGE column, but this is not working. Any suggestions.

Thanks once again.