1

My requirement is to insert img src values into table and then display in on the apex page. How can I do that?

I have created a function which inserts the img src into CLOB column But incase the length exceeds 32000 it doesnt insert it to the CLOB column

Gina Gina
  • 2,915
  • 2
  • 10
  • 16
  • Have a look at this one: https://stackoverflow.com/questions/42085147/can-i-store-binary-string-in-clob-column/42086105#42086105 – Wernfried Domscheit Oct 20 '18 at 10:05
  • Thanks for the link - but I'm a bit cofused here.I should be converting my base64 encoded to blob, store it to the table and to display it - I need it to convert it back to clob.Is it? – Gina Gina Oct 21 '18 at 17:50
  • In my link I provided two functions for conversion in both ways, what do you need? – Wernfried Domscheit Oct 21 '18 at 18:02
  • @WernfriedDomscheit What do u suggest I do here - I have a base64 encoded string - which is a data URI , should I convert it to BLOB, insert it to table and then for display - convert it back to CLOB? – Gina Gina Oct 22 '18 at 06:37
  • Also, the base encoded string has the character limit for CLOB and BLOB. – Gina Gina Oct 22 '18 at 08:12

1 Answers1

2

The fact that your data is getting truncated at 32000 characters (probably actually 32767) means you have some intermediate VARCHAR2. Other than that, there's not enough information here.

Once you get your base64 encoded data, to display it on an Apex page, the easiest way to do that is with a PL/SQL region and the htp package. None of the native htp functions support CLOBs, so you will have to output it in chunks. Something like this:

i:= 1;
loop
    l_chunk := dbms_lob.substr( l_b64_clob, l_chunk_size, i );
    exit when l_chunk is null;
    htp.prn( l_chunk );
    i := i + l_chunk_size;
end loop;

I suggest you write a reusable procedure to do this.

eaolson
  • 14,717
  • 7
  • 43
  • 58