quicksql icon indicating copy to clipboard operation
quicksql copied to clipboard

Add PROXY_USER context when the "Audit Columns" setting is enabled

Open kamilrybicki opened this issue 5 months ago • 1 comments

Copied my idea from APEX ideas app: https://apexapps.oracle.com/pls/apex/r/apex_pm/ideas/details?idea=FR-4566

Idea Summary Enhance the "Audit Columns" setting in Quick SQL by including the PROXY_USER context from USERENV when setting the created_by and updated_by columns in the generated triggers. Currently, the value is set using:

:new.created_by := coalesce(sys_context('APEX$SESSION','APP_USER'),user);
:new.updated_by := coalesce(sys_context('APEX$SESSION','APP_USER'),user);

This should be extended to also include sys_context('USERENV','PROXY_USER') to better support proxy users.

Use Case In projects where proxy user is used the actual user performing the action may be available via sys_context('USERENV','PROXY_USER'). The current implementation in Quick SQL ignores this context, resulting in audit columns capturing the database user (USER) or the APEX user, but not the true acting user. This leads to incomplete or misleading audit information.

Preferred Solution I see two options.

  1. The “Audit Columns” setting should always include code sys_context('USERENV','PROXY_USER') in generated triggers.
  2. A new setting will be added (for example, in the Options section) called "Proxy Users" or something similar. After enabling it, the code sys_context('USERENV','PROXY_USER') will be added to generated triggers.

kamilrybicki avatar Jul 18 '25 14:07 kamilrybicki

I've got 80 developers who want this in Quick SQL. There is no reason not to do this. Proxy users were available in Oracle 9i, and are in use by many organizations. :new.created_by := coalesce(sys_context('APEX$SESSION','APP_USER'), sys_context('userenv','proxy_user'), user); :new.updated_by := coalesce(sys_context('APEX$SESSION','APP_USER'), sys_context('userenv','proxy_user'), user);

RichardSoule avatar Sep 04 '25 16:09 RichardSoule