Monday, 19 May 2025

Program logging

I was asked this morning how often user X had run procedure Y in the past few months. I explained that Priority saves (to the best of my knowledge) such data in the form of saved reports for a few days and then I delete those reports. Of course, I had deleted the reports this morning so I couldn't give any data.

What I could do was add logging procedure usage to Priority. First I defined a table TEST_PROGUSERS:

FieldTypeWidthTitle
PROGINT13> Procedure
USERINT13> User
CURDATEDATE14Date
DETAILSRCHAR48Details

Then I built a read-only form based on this table; this form is a son form of EPROG, the procedure generator. In the procedures who usage I want to track I added the following statement

INSERT INTO TEST_PROGUSERS (PROG, USER, CURDATE, DETAILS) SELECT EXEC.EXEC, SQL.USER, SQL.DATE, STRCAT (DTOA (:$.FDT, 'DD/MM/YY'), ',', DTOA (:$.TDT, 'DD/MM/YY')) FROM EXEC WHERE EXEC.ENAME = '$' AND EXEC.TYPE = 'P';

The 'details' field is supposed to contain the values of the parameters passed to the procedure. 

Now I can see at a glance who has run a given procedure and when, without having to rely on saved reports (which even if they exist are inaccurate as someone could send the output to Excel, thus preventing the report instance being saved).

No comments:

Post a Comment