Skip to content
Advertisement

Use v(‘APP_USER’) as default value for column in Oracle Apex

I am trying to use v(‘APP_USER’) as default value for a column. I get null when I use it in select like

But when I use it as default in column, like below, I am getting error.

Error

Can anyone explain this or have a turnaround for this ??

Advertisement

Answer

There are other options than V(‘APP_USER’). Since Apex 5, the APP_USER is stored in the sys_context and that is a lot more performant than the V() function. It is available as SYS_CONTEXT('APEX$SESSION','APP_USER').

It also works as a default value for tables:

That being said, the best practice for audit columns is a trigger that populates the the 4 audit columns (as @Littlefoot suggested). Have a look at quicksql (under SQL Workshop > Utilities or on livesql.oracle.com). You can have it generate the triggers for you if you set “include Audit columns” and “Apex Enabled”. An example of such a generated trigger is:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement