Written by

Question CM Wang · Jul 14, 2017

The command to kill all globals given the namespace

Hi,

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

Thanks.

Comments

Rubens Silva · Jul 14, 2017

/// 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") }

0
ramya sri  Jan 8, 2019 to Alexander Koblov

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

0
Alexander Koblov · Jul 14, 2017

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

0
John Murray  Jan 8, 2019 to ramya sri

Restore your backup?

0
Pete Greskoff  Jan 8, 2019 to ramya sri

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?

0
Ed de Moel · Jul 17, 2017

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.

0
John Murray · Jul 17, 2017

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

0