User bio
404 bio not found
Member since Jan 20, 2016

So, there's 2 ways to read this, either we want an "exists" check, or following the SQL, we want a count of all instances.   This snippet can be set to do either case based on the existscheck boolean.  Ideally though, you would have an index defined, and this could be read much more efficiently than having to scan an entire global

set count=0
set existscheck=0 //Set to 1 if we only want to find first instance
set targetValue=1329
set key = ""
for   {
    set key = $ORDER(^DataTest(key))
    if targetvalue = +$LG(^DataTest(key),2) do $INCREMENT(count)
w !,"Count value is "_count
Open Exchange applications:
Certifications & Credly badges:
Global Masters badges: