The customer app from the series Building a customer app in Uniface 10 keeps logs: imports, exports, logins, job runs, purges. A retention service deletes old rows according to rules like "import log: keep 30 days". The last stage added a form for it.

Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, October 2026. The app uses SQLite through the SLE driver (SQLite 3.50.2).

The service

The purge operation takes a dry-run flag and returns one row per active rule (kind, days, number of rows) and the total:

public operation PURGE params numeric pDryRun : IN string pData : OUT numeric pTotal : OUT string pError : OUT endparams 

In a dry run it only counts. Both kinds of runs are written to the purge log, with the flag.

One entry for both runs

entry RUN_PURGE params numeric pDryRun : IN numeric pTotal : OUT endparams variables string vData, vError endvariables pTotal = 0 activate "RETAIN2_SVC".PURGE(pDryRun, vData, pTotal, vError) if ($status < 0) rollback INFO.RET_DMY = vError return -1 endif commit if (pDryRun = 1) call SHOW_PURGES(vData, "Dry run, nothing deleted:") else call SHOW_PURGES(vData, "Deleted:") endif return 0 end 

After a successful call the form commits in both cases, so the purge log keeps the dry runs too. (An earlier stage of the project had a form that rolled back after a dry run and lost exactly that log row.)

The button

A separate "Purge: dry run" button exists, but "Purge now..." does not rely on the user having pressed it:

entry DO_PURGE variables numeric vTotal endvariables call RUN_PURGE(1, vTotal) if ($status < 0) return -1 endif if (vTotal = 0) INFO.RET_DMY = "Nothing to delete." return 0 endif askmess/question "Delete %%(vTotal) row(s) now? This cannot be undone.~Purge", "Yes,No" if ($status != 1) INFO.RET_DMY = "Purge cancelled; dry run shown." return 0 endif call RUN_PURGE(0, vTotal) if ($status < 0) return -1 endif INFO.RET_DMY = "%%(vTotal) row(s) deleted." return 0 end 

The confirmation contains the number of rows that will be deleted. Without a dry run, a question like "Delete old data?" says nothing. With the number, a surprise is visible before anything happens: 2 is expected, 20000 is not.

Click test

Test data: two import log rows from early September, written into a copy of the test database before the app was started. Rule: import log, keep 30 days.

  • "Due purges": import log older than 30 days, 2 rows.
  • "Purge now...", answer No: "Purge cancelled; dry run shown." Nothing deleted.
  • "Purge now...", answer Yes: "2 row(s) deleted."
  • "Due purges" again: 0 rows.
  • The purge log had three dry runs (one from the dry-run button, two from "Purge now...") and one real run.

Notes

  • If an action deletes data, run it as a dry run first and put the result into the question.
  • If nothing is due, do not ask at all ("Nothing to delete.").
  • The dry run costs one extra pass over the data. For log tables in a desktop app that was not noticeable.