Question
Ahmad Bukhtiar · Feb 25, 2021

How to use lookup function ignoring first 4 chars and do the match

Hi 

I am using below function and it works fine but i want to match the value ignoring the first 4 chars as they are only added to sort the data.

##class(Ens.Rule.FunctionSet).Lookup

For example

My table has following values

0001EMRNameB

0002EMRNameA

0003EMRNameC

w ^Ens.LookupTable("EMRName","0002EMRNameA") this works 

But i want to use something like that

w ^(Ens.LookupTable("EMRName","%EMRNameA") this doesnt works 

00
2 0 3 94
Log in or sign up to continue

Replies

Have you considered using SQL for this rather than going directly to the globals?

SELECT DataValue FROM Ens_Util.LookupTable WHERE TableName = 'EMRName' AND KeyName LIKE '%EMRNameA'

Sample code using Embedded SQL:

set tName="EMRNameA"
set tEMRNameLike="%"_tName

&SQL(SELECT DataValue INTO :tValue FROM Ens_Util.LookupTable WHERE TableName = 'EMRName' AND KeyName LIKE :tEMRNameLike)

if (SQLCODE = 0) {
    write "tValue:",tValue,!
} else {
    write tName_" Not found",!
}