The command to kill all globals given the namespace

Primary tabs

Hi,

Is there any COS command could kill all the globals given the namespace?

Thanks.

  • 0
  • 0
  • 314
  • 6
  • 2

Answers

You might also look into ##class(%UnitTest.Manager).WipeNamespace()

once all the globals are deleted, how to retrieve again all the globals ?

It might help us all to give better answers if we know why you are looking for these things. What are you trying to accomplish?

I'd create a new database, and then use the operating system utilities (copy and move or cp and mv) to switch the current database with the new one. That way, if there is any need for data from the "old" database, it's still retrievable.

 

 

Comments

/// Returns a list of the Globals in a Cache NameSpace (used for GUI display)<br>
/// <br>
/// <b>Parameters:</b> <br>
/// NameSpace - a Cache namespace. Default is current namespace. <br>
/// Mask - a mask, or comma-separated list of masks, to select globals. Default is "*" for all.<br>
/// SystemGlobals - boolean flag to include system globals in the results. Default is "0".<br>
/// UnavailableDatabases - a returned local array of any databases not currently accessible, i.e. array(name)=status.<br>
/// Index - Internal use only.<br>
/// IgnoreHasData - For faster list of Globals set this to 1 and the HasData column will always be FALSE.<br>
/// Mapped - Return all mapped global nodes when set to 1, the default value of this parameter is 1.
/// <br>
/// Valid masks are as follows:
/// <br>
/// ABC* - All strings starting with ABC<br>
/// A:D - All strings between A and D<br>
/// A:D,Y* - All strings between A and D, and all strings starting with Y<br>
/// A:D,'C* - All strings between A and D, except those starting with C
Query NameSpaceList(
  NameSpace As %String,
  Mask As %String,
  SystemGlobals As %Boolean,
  ByRef UnavailableDatabases As %String,
  Index As %Integer,
  IgnoreHasData As %Boolean = 0,
  Mapped As %Boolean = 1) As %Query(ROWSPEC = "Name:%String,Location:%String,ResourceName:%String,Permission:%String,Empty:%String,Keep:%String,Collation:%String,PointerBlock:%String,GrowthBlock:%String,HasData:%Boolean,Journal:%String,LockLocation:%String,HasSubscripts:%Boolean") [ SqlProc ]
{
}


set s = ##class(%SQL.Statement).%New()

do s.%PrepareClassQuery("%SYS.GlobalQuery", "NameSpaceList")
set r = s.%Execute("SAMPLE", "*")
set $namespace = "SAMPLE"
while r.%Next() { kill @r.%Get("Name") }

Take care that you don't unintentionally kill globals that may be visible in this namespace because of global mappings.