Querying Mon$Attachments table
Posted: Thu 23 Jun 2016 05:19
What is the proper way to query a Firebird Mon$ table. I run the following function to determine how many active users are attached to a database:
This function fires every 2 minutes (using timer component) and updates the figure on the task bar of the application. Even though I know the users logged in changes often the result is always the same. What am I doing wrong?
Any help would be appreciated.
regards
Bill Zwirs
Code: Select all
function TForm1.Get_UserCount: integer;
var
iUsers : integer;
begin
with MiscSQL do
begin
Close;
with SQL do
begin
Clear;
Add('SELECT COUNT(MON$ATTACHMENT_ID)');
Add('FROM MON$ATTACHMENTS');
Add('where MON$ATTACHMENT_ID <> CURRENT_CONNECTION and');
Add(' MON$SYSTEM_FLAG = 0 and');
Add(' MON$STATE = 1')
end;
ExecSQL;
iUsers := Fields[0].AsInteger;
end;
Result := 1 + iUsers;
end;Any help would be appreciated.
regards
Bill Zwirs