Published on InterSystems Developer Community (https://community.intersystems.com)

Home > How to unpack a property that is a List of Objects from a result Set

Question
Stella Ticker · Jan 31, 2020

How to unpack a property that is a List of Objects from a result Set

I am trying to get a list of all settings for all the config items of a given production using SQL . When I run the following sql as a dynamic query I am unable to access the setting names and values. Settings is a list of Ens.Config.Setting

Set query="Select Name, Production, Settings,$ListLength(Settings) "
         _"As Count from Ens_Config.Item "

Set rc=##class(%ResultSet).%New()

Set sc=rc.Prepare(query)

Set sc=rc.%Execute

While rc.Next(.sc) {

For i=1:1:Count {

  Set tSetting=$List(Setting,i)

  Set name=tSetting.Name

}

I get a LIST error on the last line! Is it possible to return objects in resultsets?

#ObjectScript #SQL #Caché

Source URL:https://community.intersystems.com/post/how-unpack-property-list-objects-result-set