Example: Removing User Sessions using IMADB
The following script creates a temporary table with commands to remove user sessions. The remove commands from the table are copied to the file system. The script will be executed within this session to terminate all user sessions from the server.
Sql script name : create_remove_sessions.sql
Removing all user sessions at all DBMS servers using imadb.
Usage:
sql <vnode::>imadb <create_remove_sessions.sql
Prerequests:
o Current user account or the vnode has to be the instance owner
o Ingres 9.x, 10.x and later releases
o 'imadb' database is created at server site successfully
o You have access to all DBMS servers
platforms: Windows 2000 + Unix + OpenVMS
Ingres releases: All
Run the following script to view the existing active sessions on all DBMS Servers:
EXECUTE PROCEDURE ima_set_vnode_domain;
SELECT *
FROM ima_server_sessions
WHERE session_id NOT IN (SELECT DBMSINFO('ima_session'))
AND client_user != ''
AND db_name != LOWERCASE('imadb');
The query can be modified depending on the requirement, for example:
...
AND effective_user <YOUR CONDITION>
AND db_name <YOUR CONDITION>
Execute the following procedure to ensure all the available DBMS servers are considered:
SET SESSION WITH DESCRIPTION='remove_sessions';
\p\g
EXECUTE PROCEDURE ima_set_vnode_domain
\p\g
DECLARE GLOBAL TEMPORARY TABLE SESSION.remove_sessions (
sql_command varchar(200)
)
ON COMMIT PRESERVE ROWS
WITH NORECOVERY;
\p\g
INSERT INTO SESSION.remove_sessions
SELECT 'EXECUTE PROCEDURE ima_remove_session'+
'(server_id = '+''''+server+''''+
', session_id = '+''''+session_id+''''+')'+
'\p\g'
FROM ima_server_sessions
WHERE session_id NOT IN (SELECT DBMSINFO('ima_session'))
AND client_user != ''
AND db_name != LOWERCASE('imadb');
\p\g
COPY SESSION.remove_sessions(sql_command= CHAR(0)nl )
INTO 'remove_sessions_temp.sql';
\p\g
\include remove_sessions_temp.sql
\q
Last modified date: 07/21/2025