OK, here's my problem. I'm try to use the encrypt function to encrypt credit card numbers. If I execute the following, it works fine:
select encode(encrypt('5252444433332222','fooz','bf'), 'hex');

So i created a function:
CREATE OR REPLACE FUNCTION update_cc(INTEGER,VARCHAR(200),INTEGER) RETURNS VARCHAR(200) AS '
DECLARE
RENAME $1 TO card_uid;
RENAME $2 TO card_no;
temp_val VARCHAR(200);

BEGIN
temp_val := (select encode(encrypt(card_no,''fooz'',''bf''), ''hex'') from credit_card where cc_uid = card_uid);

RETURN temp_val;
END;

' LANGUAGE 'plpgsql';


When i try and execute:
select update_cc(cc_uid,card_int,1) from credit_card where cc_uid = 2252;

I get the following error:
WARNING: Error occurred while executing PL/pgSQL function update_cc
WARNING: line 7 at assignment
ERROR: Function encrypt(character varying, "unknown", "unknown") does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts


I know the function exists (as you can see when I do a \df):
bytea | public | decrypt | byte
a, bytea, text
bytea | public | decrypt_iv | byte
a, bytea, bytea, text
bytea | public | digest | byte
a, text
bytea | public | digest | text
, text
boolean | public | digest_exists | text
bytea | public | encrypt | byte
a, bytea, text
bytea | public | encrypt_iv | byte
a, bytea, bytea, text
text | public | gen_salt | text
text | public | gen_salt | text
, integer
bytea | public | hmac | byte
a, bytea, text
bytea | public | hmac | text
, text, text
boolean | public | hmac_exists | text
language_handler | public | plpgsql_call_handler |
character varying | public | update_cc | inte
ger, character varying, integer



I'm assuming this has something to do with the datatypes being passed into the encrypt function but can't figure out where the problem is. Can anyone help? Thanks!