Question
· Mar 3, 2022

How to access target properties from SQL action in DTL Subtransform

Does any one could tell me how can I access the target properties from inside SQL in DTL Subtransform? For example, if I use the following statement:

SELECT ID INTO :target.SetIDPID  FROM firstlook.person WHERE  FirstName = 'Paul' - as said in documentation :

  SELECT Name INTO :target.Name FROM MainFrame.EmployeeRecord WHERE SSN = :source.SSN AND City = :source.Home.City

I get an Error: ERROR <Ens>ErrException: <PROPERTY DOES NOT EXIST>

But if I pass the value for a variable "SetIDPID" I can use it in a set action without any problem: 

SELECT ID INTO :SetIDPID  FROM firstlook.person WHERE  FirstName = 'Paul'

Product version: IRIS 2021.1
$ZV: 2021.1 (Build 215.3U)
Discussion (1)0
Log in or sign up to continue

Do you initialize your target variable as an instance of an object that has Name property? The following snippet works for me

Class Custom.Test Extends %RegisteredObject
{
Property Name As %String; 

ClassMethod SQL()
{
    set target = ##class(Custom.Test).%New()
    &sql(SELECT 'TestName' INTO :target.Name FROM MainFrame.EmployeeRecord)
    write target.Name
}
}

Also, assuming you are running your test in console, you can issue write $zerror it will tell you which property is missing (could be related to something in the source rather than the target)