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
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 functionpg_backend_pid()for
SESSION_USER, use thesession_userfunction (no parentheses!)for
MODULEandACTION, use the parameterapplication_namethere is no equivalent for
TERMINALandOS_USER: the former makes no sense in the context of PostgreSQL, the latter makes no sense at all