Article
· Aug 24, 2023 1m read

How to get database's free space programmatically

InterSystems FAQ rubric

You can see the free available space for the database using the radio button "Free Space View" in Management Portal: System Operation > Databases.

And it can be obtained programmatically by the FreeSpace query of the system class SYS.Database.

Here is an example of the code (created and executed in %SYS namespace):

 /// ZISJ.mac
 Set stmt=##class(%SQL.Statement).%New()
 Set status=stmt.%PrepareClassQuery("SYS.Database","FreeSpace")
 Set rs=stmt.%Execute()
 While rs.%Next() {
   Write !
   For i=1:1:9 {
     Write rs.%GetData(i),","
   }
 } 
Discussion (0)0
Log in or sign up to continue