cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi.

I am in a situation in which I would like DB-users to automatically run a specific SQL-script every time they connect to a specific database. Some kind of login-script which I define on the server.

Any creative minds out there who could lead me in the right direction?

Best regards

View Entire Topic

You do not need any creativity, just some RTFM on login_procedure option ;). In short, you need to do the following.

Create a procedure to do whatever you want.

CREATE PROCEDURE "DBA"."CheckLogin"() 
begin 
  -- do whatever you want 
  ... 
  -- don't forget to call sp_login_environment()
  call sp_login_environment()
end ;

Allow anyone to use it.

grant execute on DBA.CheckLogin to PUBLIC;

Make server call it during login.

set option PUBLIC.Login_procedure='DBA.CheckLogin';
Former Member
0 Likes

Hi.

Thanks a lot. Yes I did think it was a RTFM issue 🙂 I just needed the keyword to search for: Login_Procedure.

Thanks I will continue this route and I am convinced this is the what I will need.

Thanks again.