Monday, April 23, 2012

Silent exporting of globals using %GOF in Caché

I would like to know if it's possible to use "^%GOF" without user interaction. I'm using Caché 2008. ^%GO isn't an option as it's to slow. I'm using input from a temporary file for automatically answer the questions, but it can fail (rarely happens).



I couldn't find the routine of this utility in %SYS. Where is it located?



Thanks,



Answer: Using "%SYS.GlobalQuery:NameSpaceList" to get list of globals (system globals excluding).



Set Rset = ##class(%ResultSet).%New("%SYS.GlobalQuery:NameSpaceList")
d Rset.Execute(namespace, "*", 0)
s globals=""

while (Rset.Next()){
s globalName=Rset.Data("Name")_".gbl"
if (globals=""){
s globals = globalName
}else{
s globals = globals_","_globalName
}

d ##class(%Library.Global).Export(namespace, globals, "/tmp/export.gof", 7)


The only drawback is that if you have a namespace with concatination of globals exceeding the maximum allowed for a global entry, the program crashes. You should then split the globals list.





No comments:

Post a Comment