Question Michael Angeleri · Feb 24, 2022

Parameter in embedded SQL

Hello, first question for me:

Is there a way to use a class Parameter in embedded SQL without having to declare a local variable, in a similar way to how it is done with Property by preponing i% as described here. See my example:

Class Test.Test Extends %RegisteredObject
{ 
Parameter MyParam = "1";  
Property MyProperty;  
(...)
Method PerformQuery() {
    set myParamLocalVar = ..#MyParam //this is what I would like to avoid
    &sql(SELECT * FROM MY_TABLE
        WHERE MY_PROPERTY = :i%MyProperty
        AND MY_PARAM = :myParamLocalVar)
    (...)
}
}
Product version: IRIS 2020.1

Comments

Robert Cemper · Feb 24, 2022

No it is not possible.
this would require having the complete instantiated object inside your query.
If you require such functionality you should use a dynamic query
where you pass the i%* as a query parameter out of your actual running context.

0