collect user access
Posted in 2019
Topics: Stored Procedures & SPL, Transactions, Locking & Isolation
Hi,
I have used one procedure to collect all access to my instance, but I am
veryfing that there are to many duplicated records.
Can someone help me to do it in the correct way, to have one record with the
information about session, process, program, hostname and database.
My procedure:
CREATE PROCEDURE public.sysdbopen()
SET ISOLATION TO DIRTY READ;
INSERT INTO connect_log
(cl_sid,cl_pid, cl_program,cl_hostname,cl_database)
SELECT UNIQUE sid, pid, progname, hostname, sqs_dbname
FROM sysmaster:sysscblst, sysmaster:syssqlstat
WHERE sid = DBINFO("sessionid");
END PROCEDURE;
Thanks for any help,
SP (sergio.peres@airc.pt)
You are not giving any condition for the join, so you have the cartesian join (or cross join) of the 2 tables filtered by ypur session id. Removing duplicates with unique is not the correct way to get the result you expect. On an Informix version 12.10.FC12DE with a single active session that query is giving me 3 results. What you probably want is something like this: SELECT a.sid , a.pid , a.progname , a.hostname , b.sqs_dbname FROM sysmaster:sysscblst AS a INNER JOIN sysmaster:syssqlstat AS b ON a.sid = b.sqs_sessionid WHERE a.sid = DBINFO( 'sessionid' ) ; I would also add a timestamp and the username to this query, but maybe it is not needed.
Hi Luis, Thanks for your reply, it works like a charm :) Best regards, SP