Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert binary data to base64

Status
Not open for further replies.

mortonsa

MIS
Joined
Apr 10, 2000
Messages
59
Location
US
The data in my table in binary. Is there a way in Oracle to convert it to base64? If anyone has written a procedure to do this or knows of a function I can use I would greatly appreciate it.

Thanks!
 
If you wanted to do hexadecimal conversion, it would be easy since Oracle supplies a number format for this. The command would be something like

select to_char(1234567890,'XXXXXXXXXX') from dual;

I'm fairly sure that for base 64 you will have to write your own conversion function. Fortunately the algorithm to do this is simple. Here is some pseudo-code that should be fairly close to what you need, at least for converting positive integers.

begin
base_64_str := ''
n := {binary number to be converted}
while n <> 0
begin
base_64_str := '<' || mod(n,64) || '>' || base_64_str
n := trunc(n/64)
end
return base_64_str
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top