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?
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';
answered 27 Oct '11, 05:37
After I have used this info I will have to open the thread again.
Note that the answer from Dmitri was
What I am trying to do, is that I would like to authenticate against a OEM-database, like specified here: http://dcx.sybase.com/index.html#1201/en/dbadmin/running-s-4314706.html But in stead of modifying my app to connect using this Auth string every time:
SET TEMPORARY OPTION connection_authentication='company = company-name; application=application-name;signature=application-signature';
I would like to make the required OEM-authentication a part of a loginscript for the DBA, so that every time I use the DBA to connect to the DB I get authenticated automatically.
But, when I do this I get this error:
So are there anyone who know a way around this - making this sort of auth run as part of a loginscript?