I need to convert a db value into base64encode. I tried:
select encode(cast(est_name as text),'base64') from establishments;
It showing error
[SQL]select encode(string(cast(est_name as text)),'base64') from establishments;
[Err] ERROR: function string(text) does not exist
LINE 1: select encode(string(cast(est_name as text)),'base64') from ...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Where I am wrong? please help. thanks in advance
The character set support in PostgreSQL allows you to store text in a variety of character sets (also called encodings), including single-byte character sets such as the ISO 8859 series and multiple-byte character sets such as EUC (Extended Unix Code), UTF-8, and Mule internal code.
The bytea data type allows the storage of binary strings or what is typically thought of as “raw bytes”. Materialize supports both the typical formats for input and output: the hex format and the historical PostgreSQL escape format. The hex format is preferred.
With elmah. io's free image to Base64 encoder, it's easy to copy and paste markup or style for exactly your codebase. Simply drag and drop, upload, or provide an image URL in the controls above and the encoder will quickly generate a Base64 encoded version of that image.
Encode decode examples for string
select encode('mystring'::bytea, 'base64');
select convert_from(decode('bXlzdHJpbmc=', 'base64'), 'UTF8');
From existing column in table
select encode(mycolum::bytea, 'base64') from mytable;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With