Skip site navigation (1) Skip section navigation (2)

Problem with encode() function

From: Glenn_Wiens(at)via-christi(dot)org
To: pgsql-novice(at)postgresql(dot)org
Subject: Problem with encode() function
Date: 2004-05-21 19:50:31
Message-ID: OF31D5CA48.78E79003-ON86256E9B.006CB5CC-86256E9B.006CFF72@via-christi.org (view raw or flat)
Thread:
Lists: pgsql-novice
I have a table where I have stored plain text passwords in a varchar field.
I would like to convert these to an encoded field. I have been able to
insert values into a test table using this syntax with a literal password:

insert into testtable (name, password) values ('glenn',encode
('mypassword','base64'));

and I can read them back out with the decode(password,'base64') syntax.
This is the behavior I want.

But when I try to encode data from an existing table:

create table newtable as select name, encode(password,'base64') as password
from oldtable;

I get this error

ERROR:  Function encode(character varying, "unknown") does not exist
        Unable to identify a function that satisfies the given argument
types
        You may need to add explicit typecasts


I have tried the following casts

password::text
case(password as text)

but I still get the error:

ERROR:  Function encode(text, "unknown") does not exist
        Unable to identify a function that satisfies the given argument
types
        You may need to add explicit typecasts

Is there a way I can accomplish this task?

Thanks.



Responses

pgsql-novice by date

Next:From: Manuel SugawaraDate: 2004-05-21 22:21:32
Subject: Re: Problem with encode() function
Previous:From: Tom LaneDate: 2004-05-21 15:20:25
Subject: Re: INSTALLING POSTGRESQL 7.4.2

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group