Thread: Using chkpass() in a query

Using chkpass() in a query

From
Michael A Nachbaur
Date:
I'm trying to perform an SQL statement to extract usernames and crypt'd 
passwords from a database table, and am running into difficulties with 
chkpass.  I can run it just fine in a straight query, but when I try to use 
it on a column from an SQL statement I get an error.

scamp=# SELECT CHKPASS('foo');   chkpass
----------------:Zbcg0W4wPBNBU
(1 row)

scamp=# SELECT CHKPASS(Password) FROM EmailAddress;
ERROR:  Function chkpass(character varying) does not exist       Unable to identify a function that satisfies the given
argumenttypes       You may need to add explicit typecasts
 
scamp=# SELECT CHKPASS(Password::TEXT) FROM EmailAddress;
ERROR:  Function chkpass(text) does not exist       Unable to identify a function that satisfies the given argument
types      You may need to add explicit typecasts
 
scamp=# SELECT CHKPASS(Password::CSTRING) FROM EmailAddress;
ERROR:  Cannot cast type character varying to cstring

Does anyone have any suggestions on how I could accomplish the above?

-- 
/* Michael A. Nachbaur <mike@nachbaur.com>* http://nachbaur.com/pgpkey.asc*/

...[Arthur] leapt to his feet like an author hearing the phone ring...