When trying to return table in postgres, this my query:
CREATE OR REPLACE FUNCTION list_log_approval(IN p_create_code INTEGER,IN p_update_code INTEGER) RETURNS
TABLE(processcode integer, processname VARCHAR,id BIGINT, pleader CHARACTER VARYING,activity VARCHAR,date_plead timestamp)
LANGUAGE plpgsql AS $$
BEGIN
IF NOT EXISTS( SELECT * FROM log_approval WHERE processcode = $1 and status = 'A' or status = 'D')AND NOT EXISTS(SELECT * FROM log_approval WHERE processcode = $2 and status = 'A' or status = 'D') THEN
RETURN QUERY SELECT * from vw_list_appv;
END IF;
RETURN;
END $$;
-- i call like this
select * from list_log_approval(1070,1072)
I get the following error:
[Err] ERROR: column reference "processcode" is ambiguous
LINE 3: processcode**
why is it ambiguous?