Hi,
I finally realised how to watch and save user connections
into Sybase IQ. If you are interested you can use it.

---

CREATE TABLE DBA.a_act_big_brother (
ConnHandle unsigned bigint,
Name varchar(255) null,
Userid varchar(255) null,
-- LastReqTime varchar(255) null,
-- ReqType varchar(255) null,
-- IQCmdType char(32) null,
-- LastIQCmdTime datetime null,
-- IQCursors unsigned integer null,
-- LowestIQCursorState char(16) null,
-- IQthreads unsigned integer null,
-- TxnID unsigned bigint null,
ConnCreateTime datetime,
-- TempTableSpaceKB unsigned bigint null,
-- TempWorkSpaceKB unsigned bigint null,
IQconnID unsigned bigint null,
-- satoiq_count unsigned bigint null,
-- iqtosa_count unsigned bigint null,
CommLink varchar(255) null,
NodeAddr varchar(255) null,
-- LastIdle integer null,
-- MPXServerName varchar(128) null,
-- LSName varchar(255) null,
AppInfo varchar(255) null,
DisConnTime datetime null,
MovedToIQ smallint null
) IN SYSTEM;

CREATE TABLE DBA.a_big_brother (
ConnHandle unsigned bigint,
Name varchar(255) null,
Userid varchar(255) null,
-- LastReqTime varchar(255) null,
-- ReqType varchar(255) null,
-- IQCmdType char(32) null,
-- LastIQCmdTime datetime null,
-- IQCursors unsigned integer null,
-- LowestIQCursorState char(16) null,
-- IQthreads unsigned integer null,
-- TxnID unsigned bigint null,
ConnCreateTime datetime,
-- TempTableSpaceKB unsigned bigint null,
-- TempWorkSpaceKB unsigned bigint null,
IQconnID unsigned bigint null,
-- satoiq_count unsigned bigint null,
-- iqtosa_count unsigned bigint null,
CommLink varchar(255) null,
NodeAddr varchar(255) null,
-- LastIdle integer null,
-- MPXServerName varchar(128) null,
-- LSName varchar(255) null,
AppInfo varchar(255) null,
DisConnTime datetime null
);

CREATE EVENT user_connects
TYPE [CONNECT]
DISABLE
HANDLER
BEGIN
declare connid integer;
declare local temporary table iq_connTable(
Number unsigned bigint null,
IQconnID unsigned bigint null,
IQCmdtype char(32) null,
LastIQCmdTime datetime null,
IQCursors unsigned integer null,
LowestIQCursorState char(16) null,
IQthreads unsigned integer null,
TxnID unsigned bigint null,
ConnCreateTime datetime null,
TempWorkSpace unsigned bigint null,
TempTableSpace unsigned bigint null,
satoiq_count unsigned bigint null,
iqtosa_count unsigned bigint null,
Dbremote bit not null, -- 12.7
-- MPXServerID unsigned integer null,
-- LSID unsigned bigint null,
) in SYSTEM on commit preserve rows;
if event_parameter( 'User' ) not in
('DBA','dbo','bo_user') then -- eliminace systemovych uctu
execute immediate with quotes on 'iq utilities main into
iq_connTable command statistics 20000';
set connid = event_parameter( 'ConnectionID' );
insert a_act_big_brother
select connid as ConnHandle,
connection_property('Name',connid),
connection_property('Userid',connid) as Userid,
ConnCreateTime,
IQconnID,
connection_property('CommLink',connid),
connection_property('NodeAddress',connid),
connection_property('AppInfo',connid),
null as DisConnTime,
0 as MovedToIQ
from iq_connTable
where Number = connid
and Userid is not null;
end if;
drop table iq_connTable;
END
go

CREATE EVENT user_disconnects
TYPE [DISCONNECT]
DISABLE
HANDLER
BEGIN
if event_parameter( 'User' ) not in
('DBA','dbo','bo_user') then -- do not remember system
accounts
update a_act_big_brother set DisConnTime = current
timestamp
where ConnHandle = event_parameter( 'ConnectionID' );
end if;
END
go

-- Reseni exkluzivniho pristupu k archivni IQ tabulce.
CREATE EVENT arch_big_brother
SCHEDULE
START TIME '00:02AM' EVERY 10 MINUTES
DISABLE
HANDLER
BEGIN
update a_act_big_brother set MovedToIQ = 1
where DisConnTime is not null;
insert a_big_brother
select ConnHandle, Name, Userid, ConnCreateTime,
IQconnID, CommLink, NodeAddr, AppInfo, DisConnTime
from a_act_big_brother
where MovedToIQ = 1;
delete a_act_big_brother
where MovedToIQ = 1;
END
go