Otto Medin · May 18, 2017 go to post

That counts the first-level subscripts, but it ignores the root node, as well as deeper-level subscripts, e.g:

USER>set (^x, ^x("a"), ^x("b","c"), ^x("b","d")) = ""
 
USER>set global=$name(^x),count=0
 
USER>set i="" for { set i=$o(@global@(i)) quit:i=""  if $increment(count) }
 
USER>write count
2

Otto

Otto Medin · May 22, 2017 go to post

Hi,

A couple of questions, in order to better understand what to recommend:

  1. Is the Caché instance where you're running the script an ECP client of the remote Caché instance?
  2. I can't quite parse "on just one server for all server". Is there a typo in there somewhere?

Cheers,

Otto

Otto Medin · Jun 16, 2017 go to post

([@Kyle Baxter]: Your answer is in response to [@Scott Morrison]'s comment, right?)

Another thing to consider is that child objects have non-integer IDs, so you can't use bitmap or bitslice indices on their properties.

Otto Medin · Jun 16, 2017 go to post

...or did you already have data in the table when you added the index on A? Assuming that some or all of the pre-existing data is in your WHERE range, that would explain your problem, and as others have commented, an index rebuild is the remedy.

Otto Medin · Aug 7, 2017 go to post

This only matters for very long loops (and you'd need a pretty extreme scenario for it to matter even then), but a post-conditional 'quit' is only meaningful if there's more code after it, and it comes with a performance cost, so this line:

USER>for count = count:1 set ref=$query(@ref) quit:ref=""

...should be:

USER>for count = count:1 set ref=$query(@ref) if (ref="") quit
Otto Medin · Aug 7, 2017 go to post

Hi Kishan,

The error message indicates that you're trying to access a property called 'value' in a collection of objects (%Collection.ListOfObj), but there is no such thing. My guess is that you're trying to access a property of one of the objects in the collection, in which case you need to use the 'GetAt' method of the collection object to specify which one you're after.

Here's more information on how to handle collections of objects.

Otto

Otto Medin · Aug 16, 2017 go to post

...and don't forget to kill the global when you're done. On a busy system, the log file could grow very large.

Otto

Otto Medin · Nov 8, 2017 go to post

Somewhat off-topic, there are reasons to watch out for %OnBeforeSave():

  • The object is already serialized at this point, so you can't change any properties.
  • The method is only triggered if the object was changed.

%OnAddToSaveSet() has neither of these gotchas (but you don't have %Id() there either, of course).

Otto Medin · Jan 24, 2018 go to post

Agreed, and if you want to have your cake and eat it, too:

if (a) { set b = a }
Otto Medin · Mar 22, 2017 go to post

Hi,

Ensemble has a piece of infrastructure to handle parallel calls. Here's how to run it:

for tCounter = 1:1:10 {
   set tCall = ##class(Ens.CallStructure).%New()
   set tCall.TargetDispatchName = ”MyBusinessHostClass"
   set tCall.Request = ##class(MyRequestClass).%New()

   set tCall.Request.MyProperty = "Some value"
   set tRequestList(tCounter) = tCall
}
set tTimeout = 10
set tSC = ..SendRequestSyncMultiple(.tRequestList, tTimeout)

After that finishes, you can access the individual responses like this:

for tCounter = 1:1:10 {
   set tStatus = tRequestList(tCounter).ResponseCode
   set tResponse = tRequestList(tCounter).Response
}

Hope that's what you're looking for,

Otto

Otto Medin · May 9, 2017 go to post

Hi Steve,

Here are a couple of ways to do this:

1. Use ^%GSIZE to look at the size of your index global before and after you populate your new index. (If you look at the class definition, the global name is listed as "IndexLocation" in the "Storage" section.)

2. Map the index global to a separate database and look at the size of the CACHE.DAT.

The advantage of the second approach is that subscript-level mapping lets you selectively isolate indices.

Otto

Otto Medin · May 17, 2017 go to post

Hi Jiri,

The article you're referring to is from the early days of Ensemble, when we used an adapter library from a partner. This arrangement changed a few years ago, when the important needs of our users were sufficiently covered by our native adapter library. At that point, support for some non-critical interfaces was dropped.

I've looked around for examples of AS2 use with Ensemble, but so far I've drawn a blank. Perhaps others can comment, but failing that, my advice is that you speak to your local InterSystems representatives about your requirements and potential ways forward.

Kind regards,

Otto

Otto Medin · May 18, 2017 go to post
USER>set (^x, ^x("a"), ^x("b","c")) = ""
 
USER>set ref = "^x", count = $data(@ref)#2
 
USER>for count = count:1 set ref=$query(@ref) quit:ref=""
 
USER>write count
3
USER>

Perhaps someone has a more elegant way to make sure the root node gets counted...?

Otto

Otto Medin · Jun 8, 2017 go to post

Depending on the exact behavior you're after, the "binary follows" operator (]) may do the trick. For your two values, it yields the desired result, regardless of how you set them:

USER>set a = "1.0", b = "2.2" write a]b
0
USER>set a = "1.0", b = 2.2 write a]b
0
USER>set a = 1.0, b = 2.2 write a]b
0
USER>set a = 1.0, b = "2.2" write a]b
0
Otto Medin · Apr 15, 2020 go to post

Hi Dimitry,

Was the webinar recorded? I'd say you'll get at least another 80 viewers if you publish it...

Cheers,

Otto

Otto Medin · Dec 10, 2020 go to post

...or using a stored procedure along these lines:
ClassMethod RenameTable(oldName As %String, newName As %String) As %String [ SqlProc ]
{
   try {
      &sql(select %ID into :className
         from %Dictionary.ClassDefinition
         where SqlTableName = :oldName
      )
      if SQLCODE set status = "Error: Table '" _ oldName _ "' not found." quit
      set classDef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
      set classDef.SqlTableName = newName
      set saveStatus = classDef.%Save()
      set status = $case(saveStatus, 1: "OK", : "Error: " _ $system.Status.GetErrorText(saveStatus))
   } catch {
      set status = "Error: " _ $zerror
   }
   return status
}
Note: This doesn't handle the special case where there is no 'SqlTableName' defined.

Otto Medin · Oct 29, 2021 go to post

Note that applying the new IRIS for Health key (I haven't tried plain IRIS) yields a warning that it lacks some of the analytics features of the expiring key.

Otto Medin · Mar 25, 2024 go to post

Thanks Dimitrii, your question answered my question (how to get rid of the trailing slash).