Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » How to store the Emp_name instead of username in application Item (apex 4.1)
How to store the Emp_name instead of username in application Item [message #555784] Mon, 28 May 2012 23:00 Go to next message
gurujothi
Messages: 80
Registered: January 2012
Location: Banglore
Member

Hello Everyone,
Am using Apex 4.1,
In my application am using custom authentication,
By default, APEX application will store the USERNAME in APP_USER Item right?
Is this possible to fetch the Emp_name and store in the application item from some other table based on the username during the login time,
For example,
"EMP" table(If it has the following columns)
emp_name
username


select emp_name from EMP where username= :p101_username --- and this value should be stored into the Application ITEM, something like this.
Thank you.
Re: How to store the Emp_name instead of username in application Item [message #555785 is a reply to message #555784] Tue, 29 May 2012 00:08 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
No problem. I'd only use APP_USER instead of P101_USERNAME:
select emp_name 
from emp 
where upper(username) = :APP_USER
Re: How to store the Emp_name instead of username in application Item [message #555787 is a reply to message #555785] Tue, 29 May 2012 00:16 Go to previous messageGo to next message
gurujothi
Messages: 80
Registered: January 2012
Location: Banglore
Member

Hi Littlefoot,
Can I use this in my following package code,
function CUSTOMAUTHENTICATION
(p_username in VARCHAR2,
p_password in VARCHAR2)
return BOOLEAN
is
  v_cnt pls_integer := 0;
  v_emp  varchar2(100); 
begin
  
 SELECT 1 INTO v_cnt 
              FROM app_user
            WHERE UPPER (username) = UPPER (p_username)
     AND PASSWORD = get_hash (p_username, p_password);
  
  select emp_name into v_emp
      from users1 where UPPER(username)= UPPER(p_username); 
 
  
   APEX_UTIL.SET_SESSION_STATE('FUSER',UPPER(v_emp)); 
    RETURN TRUE;
APEX_UTIL.SET_SESSION_STATE('FUSER');

     RETURN FALSE;
 
end CUSTOMAUTHENTICATION;

actually the above 1 is not showing the emp_name still it showing username,
Re: How to store the Emp_name instead of username in application Item [message #555791 is a reply to message #555787] Tue, 29 May 2012 00:46 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I wouldn't know. I never used these APEX_UTIL procedures.

Though, what is the purpose of "SELECT 1 INTO V_CNT"? If WHERE clause causes nothing to be retrieved, the whole function will fail with NO-DATA-FOUND (which you didn't handle).
Re: How to store the Emp_name instead of username in application Item [message #555794 is a reply to message #555791] Tue, 29 May 2012 00:57 Go to previous messageGo to next message
gurujothi
Messages: 80
Registered: January 2012
Location: Banglore
Member

Hi Littlefoot,
"SELECT 1 INTO V_CNT" This line is just to check whether the user is exist in the APP_USER table during the login time.
Re: How to store the Emp_name instead of username in application Item [message #555795 is a reply to message #555794] Tue, 29 May 2012 01:00 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If it doesn't, your code (as it is written now) will fail.
Re: How to store the Emp_name instead of username in application Item [message #555798 is a reply to message #555795] Tue, 29 May 2012 01:06 Go to previous messageGo to next message
gurujothi
Messages: 80
Registered: January 2012
Location: Banglore
Member

Can you tel how to modify it?
Re: How to store the Emp_name instead of username in application Item [message #555800 is a reply to message #555798] Tue, 29 May 2012 01:23 Go to previous message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Handling PL/SQL Errors.
Previous Topic: how to update the column in table based on the value selected in apex4.1
Next Topic: IR Report Group by issue
Goto Forum:
  


Current Time: Thu Dec 12 07:29:14 CST 2024