Are Config.* classes backwards compatible to previous versions of the cpf format?


I am running the latest version of Cache and am trying to use the Config.* classes in the %SYS namespace to be able to gather information from a cache.cpf file that was provided to me by a customer.  The customer is running an older version of Cache which had a different Version number in the cpf file.  Theirs is 2013.1 and mine is 2015.1.  

My question is, are the Config.* classes backwards compatible.  Can I use a 2017.1 version of Cache to read information from cpf file from a 2014 system?

  • 0
  • 0
  • 171
  • 11
  • 1


Hi Ken,

For some odd reason Execute() requires he same parameters as Prepare() again !

%SYS>set rs=##class(%ResultSet).%New("Config.MapGlobals:List")
%SYS>write rs.Prepare("ENSDEMO","*")
%SYS>write rs.Execute("ENSDEMO","*")
%SYS>write rs.Next()
      Just hacking around.

Prepare doesn't require arguments, only execute does.

You can prepare query once and then execute it several times with different arguments.

as the class  is deployed YOU may have access to the sources.

It's in the docs:

The query may contain parameters represented by ? characters within the query. The values of any parameters are supplied via the Execute method.

That's fine and nothing new.
You missed my point:

With the Class Query it's not self explaining if params got to Prepare() or to Execute()

I just learned from  John Murray a few comments above

Prepare() is for dynamic SQL, but in your case it's a class query you want to run.
So change your rs.Prepare call to be an rs.Execute one.

that you don't need a prepare with a Class Query.
I wasn't aware of that until a few hours ago.

Then it's obvious that any param has to go to Execute().


If you want to execute a class query and get a result set you can directly call <Query>Func method and get a new %SQL result set:

set rs = ##class(Config.MapGlobals).ListFunc("ENSDEMO","*")
while rs.%Next() {
  w rs.Name,!

The only case where you can't use that if you need to choose the query at runtime.


Interesting question. What have your attempts shown so far?

I was able to use the Config.Namespaces (Exists) method to determine if a given namespace was defined and also to gather attributes for it.

I am attempting to use the List query of the Config.MapGlobals class to gather global mappings for the namespace and it's not returning anything.  



Presumably you've verified that your code for doing that does work as expected when it's processing your instance's own CPF?

Interestingly I just tried to use the List query to gather global mappings for a namespace in the active configuration and it didnt return anything..

%SYS>s rs=##class(%ResultSet).%New("Config.MapGlobals:List")

%SYS>s sc=rs.Prepare("HSEDGEREST","*")

%SYS>w sc


%SYS>w rs.Next()




Am I doing something not quite right here?

Prepare() is for dynamic SQL, but in your case it's a class query you want to run. So change your rs.Prepare call to be an rs.Execute one.


Or use the following as a quick verification:

%SYS>d ##class(%ResultSet).RunQuery("Config.MapGlobals","List","HSEDGEREST","*")