user1544327
user1544327

Reputation: 117

How to user app_user in the where condition

using v('APP_USER') in where condition is returning to null records

select FULL_NAME, EMAIL_ADDRESS from headcount where EMAIL_ADDRESS = v('APP_USER')

Upvotes: 1

Views: 3124

Answers (2)

Koen Lostrie
Koen Lostrie

Reputation: 18630

There are 3 ways to get the value of APP_USER in an apex session. The preferred way is the bind variable (:APP_USER) but you can you also use the sys_context variable SYS_CONTEXT('APEX$SESSION','APP_USER') or the V function (V('APP_USER')). To prove that works I created a report with the following query:

WITH app_user_tab AS (SELECT 'bind var' as type, :APP_USER as username FROM DUAL
UNION
SELECT 'context',SYS_CONTEXT('APEX$SESSION','APP_USER') FROM DUAL
UNION
SELECT 'v', v('APP_USER') FROM DUAL)
SELECT * FROM app_user_tab

And i got 3 identical rows as expected.

Which leads me to believe your problem is not with the app user, but with the value in headcount.email_address. It could be:

  • case not matched.
  • leading/trailing control characters in the headcount.email_address column

Upvotes: 1

mohamad subhi bouchi
mohamad subhi bouchi

Reputation: 190

you have to use bind variables in your sql. V / NV functions are used in compiled code, such as views, packages, and procedures.

more info are here

Upvotes: 0

Related Questions