I am moving on to Postgresql, but you are facing a problem.
The “trick” I use with SQL Server is always using a single user (typically sa), and I write program_name in connection with the database to check the number of currently registered users in the application. Each time I connect db for UserX, I set the computer_name in the connection as "MyApp_UserX". Thus, using the following query, I can calculate how many users are connected to my application. I use this to check the license and it is very reliable in sql server.
select count(sp.loginame) as CNT
from Master.dbo.sysprocesses sp
join Master.dbo.sysdatabases sd on sp.dbid = sd.dbid
where sd.name = MYDATABASE and sp.program_name like 'MyApp%'
Now Postgresql does not allow me to specify a string of type program_name in communication. What can you offer?
For Delphi users: Note. I am using unidac, moving from SDAC. in SDAC I had TMSConnection.ApplicationName but no Postgresql equivalent.
source
share