In this post I'm going to look at a simple example of querying the SPF database to check a problem reported by an end-user. Of course, each SPF installation is different and the specific queries shown here are probably not applicable to your site, but APSR automatically adapts to the local SPF Schema and will generate queries based on your site's configuration.
In this example, a company requirement is that each Document in SPF with a Microstation DGN file must also have an associated PDF file (for viewers who can't work with DGN's). End-users have reported that some DGN documents do not have the accompanying PDF file.
How do we find these documents, and determine how big the problem is?

This Virtual Table represents the ISPFDocumentVersion InterfaceDef in SPF. We can base our queries on either a ClassDef or an InterfaceDef, depending on our requirements. By using the InterfaceDef our results will include all Classes which use this Interface.

We now need to create two sub-queries. The first will count the number of PDF's associated with a Document Version, and the second will count the number of DGN's. To create a sub-query, we add a Derived Table to our query.



This sub-query needs to count the number of PDF's associated with each Document Version, so we Group by the appropriate fields, filter by the LocalFileName field (%.pdf) and then Count the results.


(Note that my sample data is virtual empty, so I don't see a lot of results with this database).


We could also filter by selected ClassDefs, and should probably only included Versions that are not Superseded. Both are simple filters.
In fifteen minutes we've got a detailed list of problem documents. If there are only a few to be fixed, perhaps someone can do it manually, but if there are many hundreds, then that would indicate some type of systemic problem.
APS Reporter/SP is a great tool for adhoc queries, and everything I've shown here can be done with the Free License, so it's simple to get started with it.
If you have any queries, post a comment below of contact me at one of the links to the right, where you will also find a download link for the free version.
Regards,
Brian Raynor.
No comments:
Post a Comment