WARNING: Error occurred while executing PL/pgSQL function correctaddress
WARNING: line 8 at SQL statement
ERROR: column "addressid" is of type integer but expression is of type character varying
You will need to rewrite or cast the expression
And the function looks like:
CREATE FUNCTION correctAddress(INT) RETURNS INT AS '
DECLARE
user_id ALIAS FOR $1;
old_addr INT;
new_addr INT;
BEGIN
PERFORM nextval(''public.address_addressid_seq'');
INSERT INTO address (SELECT strProvince, strAddress FROM address WHERE addressID = (SELECT addressID FROM companies WHERE companyID = (SELECT companyID FROM users WHERE userID=user_id)));
UPDATE users SET adressID = CAST(currval(''public.tbladdress_addressid_seq'') AS INTEGER) WHERE userID=user_id; -- ---> ^ ^ ^ ^ ^ ^ = ?
RETURN 1;
END ' LANGUAGE 'plpgsql';
It's probably something simple that I'm doing wrong. Can anyone help?
Postgres 7.4.1
Thanks
Ron
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster