Consultor Eletrônico



Kbase P14082: How to limit the number of user connections using 4GL code ?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/31/2005
Status: Verified

GOAL:

How to limit the number of user connections using 4GL code

GOAL:

How ensure the number of database connections does not exceed a set limit using the 4GL

GOAL:

How to control the number of connections with 4GL code

FIX:

Use a FOR EACH ... WHERE .... loop on the _Connect Virtual System Table (VST) to count the current number of connections.
If the number of connections exceeds the limit, end the session using the QUIT statement.

Set the WHERE clause to either filter by username (_Connect._Connect-Name), or by connection type (_Connect._Connect-Type).
When filtering by connection type, the values SELF and REMC indicate user connections.

An example that counts per connection type:

DEF VAR Count AS INTEGER INIT 0.
DEF VAR Maximum AS INTEGER INIT 20.

FOR EACH _Connect :
IF _Connect._Connect-Type = "SELF" OR
_Connect._Connect-Type = "REMC" THEN Count = Count + 1.

IF Count > Maximum THEN QUIT.
END.
Remember that to access the VST's of a database, a connection to that database is required.