问题
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
回答1:
The encode function encodes from bytea to text.
select encode(est_name::bytea, 'base64')
from establishments;
http://www.postgresql.org/docs/current/static/functions-binarystring.html#FUNCTIONS-BINARYSTRING-OTHER
来源:https://stackoverflow.com/questions/23698719/postgresql-base64-encode