I want to base64-encode all names in a table. (PostgreSql)
What does seem logical to me, doesn't work.
I tried:
update person
set name = encode(name, 'base64');
throws an error:
ERROR: function encode(character varying, unknown) does not exist
SELECT encode('test, 'base64');
-> works without problems
How can I pass the value of 'name' to the function?
CodePudding user response:
encode
takes bytea
as first argument. So you can use
encode(CAST (name AS bytea), 'base64')