Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Help with class query in SYS.Database

Question
George Hodder · Feb 19, 2021

Help with class query in SYS.Database

Hi,

I am wanting to get the results of SYS.Database class's List query into a result set.

I have code that does it, but I get a cursor error at the end.... should I just to a try/catch and ignore this error below?  Or can I call this in a different way to avoid the error?  

My code, in the %SYS namespace

Set Statement=##class(%SQL.Statement).%New()
Set status=Statement.%PrepareClassQuery("SYS.Database","List")

Set rset=Statement.%Execute()
//
while (rset.%Next())
{
        W !,rset.%Get("Directory"),?30,rset.%Get("Size"),?40,rset.%Get("MaxSize")
}

when I call it... it displays

c:\intersystems\cache\mgr\   96        Unlimited
c:\intersystems\cache\mgr\cache\11      Unlimited
c:\intersystems\cache\mgr\cacheaudit\1  Unlimited
c:\intersystems\cache\mgr\cachelib\506  Unlimited
c:\intersystems\cache\mgr\cachetemp\11  Unlimited
c:\intersystems\cache\mgr\docbook\200   Unlimited
c:\intersystems\cache\mgr\ffl\10        Unlimited
c:\intersystems\cache\mgr\samples\91    Unlimited
c:\intersystems\cache\mgr\user\31       Unlimited

<CLASS DOES NOT EXIST>%CloseCursor+3^%SQL.ClassQueryResultSet.1 *SYS.Database

#Caché
Product version: Ensemble 2016.1
$ZV: Cache for Windows (x86-64) 2016.1.1 (Build 108U_SU) Thu Jul 7 2016 09:32:36 EDT

Source URL:https://community.intersystems.com/post/help-class-query-sysdatabase