19.0, Postgres - I've been working with an old application that originally started with the embedded database and one of the sore points in it is the use of "buckets" to store and show statistics. These are essentially counts of open, completed and canceled orders and shipments which are maintained via procedures update and backout in the DDs. While they do in general work well, there is the odd occurrence where the buckets are incorrect, probably caused by a user encountering some kind of crash or doing a disconnect from the server instead of logging off and the server later closes the session. Everyone is working remotely from home these days.

Anyway, I want to replace them with a few SQL calls that grab the appropriate counts when I need them. This works quite well and the only question is where to do the embedded SQL call. My thought is to simply add it to procedure update but I'm a little concerned about doing a SQL call in Update. I tried Save_Main_File but that gets hit numerous times during saving so would rather not do that. This is strictly a query, no database update or insert and executes in milliseconds so I don't really see a problem with using update but could be missing something like the locked state causing a problem that I'm not seeing here in my single user environment.

Anyone see any downsides? If so any suggestions?