Written by

Sr Sales Engineer (Public Sector) at InterSystems Corporation
Question Chip Gore · Jan 12, 2023

Needed Class Parameter specification and use that works SQLComputeCode

In trying to define a Class Parameter that I can use in SQLComputeCode I can't seem to get any of the syntaxes for the using of the parameter where the SQL compute code will actually evaluate the parameter values. There is nothing specific that I can find in the docs about SQLCompute Code and Parameter usage.

Is there some specific syntax for accessing a class defined parameter in the SQL Compute Code that works?

This is on: IRIS for Windows (x86-64) 2022.1.1 (Build 374U) Tue Oct 18 2022 17:37:34 EDT

Comments

Enrico Parisi · Jan 12, 2023

SQL Compute Code runs outside the class context, in that circumstance you can use:

##class(YourPkg.YourClassName).#YourParamName

Enrico

0
Peter Steiwer · Jan 13, 2023

I tried this and it worked:

Parameter TestParam = "Test";

Property TestCalc As %String [ SqlComputeCode = { Set {*} = ..#TestParam}, SqlComputed ];

[SQL]SAMPLES>>select * from DC.SQLCompute
1.      select * from DC.SQLCompute
 
ID      TestCalc
1       Test

0
Enrico Parisi  Jan 14, 2023 to Peter Steiwer

Often SqlComputed is used for properties that are also calculated like:

Property TestCalc As %String [ Calculated, SqlComputeCode = { Set {*} = ..#TestParam }, SqlComputed ];

but in that case ..#ParamName does not work, this works:

Property TestCalc As %String [ Calculated, SqlComputeCode = { Set {*} = ##class(test.CalcParm).#TestParam }, SqlComputed ];

Enrico

0