0

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?

asked Feb 14, 2018 at 6:50

1 Answer 1

1

processcode is used both as function parameter and as table column.

The best thing is to use function parameters with a different name, like p_processcode.

But you can also disambiguate by qualifying the name: log_approval.processcode for the column and list_log_approval.processcode for the function parameter.

answered Feb 14, 2018 at 7:15
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.