Question
Chip Gore · Jan 12

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

0
0 117
Discussion (4)3
Log in or sign up to continue

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

##class(YourPkg.YourClassName).#YourParamName

Enrico

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

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