0

I'm converting Oracle SQL to PostgreSQL. I can't find a function like Oracle in PostgreSQL. SYS_CONTEXT('USERENV', 'SESSIONID'); SYS_CONTEXT('USERENV', 'SESSION_USER'); SYS_CONTEXT('USERENV', 'OS_USER'); SYS_CONTEXT('USERENV', 'TERMINAL'); SYS_CONTEXT('USERENV', 'MODULE'); SYS_CONTEXT('USERENV', 'ACTION')

1 Answer 1

2

There are no totally identical replacements in PostgreSQL. You will have to be creative. In my opinion, the best equivalents are:

  • for SESSIONID, use the backend process ID as returned by the function pg_backend_pid()

  • for SESSION_USER, use the session_user function (no parentheses!)

  • for MODULE and ACTION, use the parameter application_name

  • there is no equivalent for TERMINAL and OS_USER: the former makes no sense in the context of PostgreSQL, the latter makes no sense at all

Sign up to request clarification or add additional context in comments.

1 Comment

terminal and os_user are provided by the SQL client to Oracle, so this could be appended to application_name if the information is needed.

Your Answer

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.