Difference between revisions of "SQL - Encode/decode function (base64)"

From GUILLARD WIKI
Jump to navigation Jump to search
 
Line 1: Line 1:
<code>
<syntaxhighlight lang="sql">
set define off;
set define off;
</code>
</syntaxhighlight>


- Encode<br/>
- Encode
<code>SELECT UTL_RAW.cast_to_varchar2(</code><br/>
<syntaxhighlight lang="sql">
&nbsp;&nbsp;<code>UTL_ENCODE.base64_encode(</code><br/>
SELECT UTL_RAW.cast_to_varchar2(
&nbsp;&nbsp;<code>UTL_RAW.cast_to_raw('Surf the world, travel & eat as much as u can... xo xo T.'))) "42"</code><br/>
  UTL_ENCODE.base64_encode(
<code>FROM dual;</code><br/>
  UTL_RAW.cast_to_raw('Surf the world, travel & eat as much as u can... xo xo T.'))) "42"
FROM dual;
</syntaxhighlight>


 
- Decode
- Decode<br/>
<syntaxhighlight lang="sql">
<code>SELECT UTL_RAW.cast_to_varchar2(</code><br/>
SELECT UTL_RAW.cast_to_varchar2(
&nbsp;&nbsp;<code>UTL_encode.base64_decode(</code><br/>
  UTL_encode.base64_decode(
&nbsp;&nbsp;<code>UTL_RAW.cast_to_raw('U3VyZiB0aGUgd29ybGQsIGxvdmUgdGhlIHdvbWVuLCBlYXQgYXMgbXVjaCBhcyB1IGNhbi4uLiB4byB4byBULg=='))) "42"</code><br/>
  UTL_RAW.cast_to_raw('U3VyZiB0aGUgd29ybGQsIGxvdmUgdGhlIHdvbWVuLCBlYXQgYXMgbXVjaCBhcyB1IGNhbi4uLiB4byB4byBULg=='))) "42"
<code>FROM dual;</code>
FROM dual;
</syntaxhighlight>

Latest revision as of 10:14, 13 April 2018

set define off;

- Encode

SELECT UTL_RAW.cast_to_varchar2(
  UTL_ENCODE.base64_encode(
  UTL_RAW.cast_to_raw('Surf the world, travel & eat as much as u can... xo xo T.'))) "42"
FROM dual;

- Decode

SELECT UTL_RAW.cast_to_varchar2(
  UTL_encode.base64_decode(
  UTL_RAW.cast_to_raw('U3VyZiB0aGUgd29ybGQsIGxvdmUgdGhlIHdvbWVuLCBlYXQgYXMgbXVjaCBhcyB1IGNhbi4uLiB4byB4byBULg=='))) "42"
FROM dual;