Skip to Main Content

SQL & PL/SQL

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!

PLSQL API for Blob (pdf file) base64 encode/ decode

User_Z8YBQJun 21 2021

hi ,
I need to decode a base64 string received as part of JSON payload from the client.
I am using the below scripts provided by Tim Hall to validate the base64 encode/decode would work or not.

https://oracle-base.com/dba/miscellaneous/base64encode.sql
https://oracle-base.com/dba/miscellaneous/base64decode.sql

For this purpose i apply these scripts on a BLOB (PDF) column in my server database.
Q1:
select dbms_lob.getlength(file_data)
from fnd_lobs
where file_id = <file_id>; -- file_data contains binary BLOB data with content type = application/pdf.
Length of BLOB : 74021
Q2:
select dbms_lob.getlength(base64decode(base64encode(file_data)))
from fnd_lobs
where file_id = <file_id>; -- file_data contains binary BLOB data with content type = application/pdf.
Length of BLOB : 74018
The PDF/BLOB generated from Q2 does not open in a PDF viewer.
Could someone please advise where am going wrong or if the scripts used need any changes? Or do we have an PLSQL API for data above 32 K?
BR,
Arun

This post has been answered by Paulzip on Jun 21 2021
Jump to Answer
Comments
Post Details
Added on Jun 21 2021
16 comments
11,047 views