Reputation: 553
I need to obtain a list of namespaces, databases, and tables in Caché so I can loop through each and query various things (like row counts).
I've seen this, but it only lists the databases within the %SYS namespace.
I know I can use LIST^%NSP
in the terminal to obtain a list of namespaces, but it has extra text ("Here are the defined namespaces:") that I don't want to have to parse. Plus, I really would like to stick to SQL queries if possible.
Thanks
Upvotes: 5
Views: 5703
Reputation: 2073
In the terminal you can write the following commands:
D ##class(%SYS.Namespace).ListAll(.result)
zw result
This will fetch you all the available namespaces.
Upvotes: 5
Reputation: 2070
To list namespaces, you want the List
query in the %SYS.Namespace
package.
To retrieve data about the contents of a specific namespace, you will need to be in that Namespace. From COS, you can use ZNSPACE
. Then, you can query %Dictionary.ClassDefinition
, as linked. Contrary to your statement, this does not query only %SYS
classes, but all classes available from the current namespace, which will (by default) include all classes that begin with a %
.
If you would like to avoid those classes, you could simply call
SELECT Name FROM %Dictionary.ClassDefinition WHERE NOT Name %STARTSWITH '%'
Upvotes: 2