How to get the execute UserID in the stored proceduere

Database
Highlighted
Enthusiast

How to get the execute UserID in the stored proceduere

Hi, Every I am developing a stored procedure, and logging all query statements. How can I get the execute user information of the stored procedure , like the userID in 【Teradata SQL history】 I have tried DBQLOGtbl, the UserID is like '00-00-09-04' Or, The same question, Where the 【Teradata SQl History】 come from ? Waiting for your help.

Accepted Solutions
Enthusiast

Re: How to get the execute UserID in the stored proceduere

I found "USER" to be hit or miss in the 15.10 version we were on before upgrading to 16.20, especially in a stored procedure. I switched all of my code over to use "CURRENT_USER" which has worked 100% of the time. 

1 ACCEPTED SOLUTION
3 REPLIES 3
Ambassador

Re: How to get the execute UserID in the stored proceduere

USER returns the user name, you can join to dbc.dbase to get the user id.

Enthusiast

Re: How to get the execute UserID in the stored proceduere

I found "USER" to be hit or miss in the 15.10 version we were on before upgrading to 16.20, especially in a stored procedure. I switched all of my code over to use "CURRENT_USER" which has worked 100% of the time. 

Enthusiast

Re: How to get the execute UserID in the stored proceduere

Thank you for your reply. It works.