Question
· Sep 29, 2023

SQL ObjectSelectMode for Object properties

Hello Community,

I have couple of question about the DynamicSQL.

1. The %ObjectSelectMode is working perfectly in the DynamicSQL for the object property in direct query. However this is not supported for class query. Is there any way to resolve this / Get the object value for class query result.

2. What is the reason behind for a stored query prepared using %PrepareClassQuery() you must use the %Get("fieldname") method.

Class Samples.DB.NewClass1 Extends %Persistent
{
Property Address As NewClass3;
ClassMethod TestQuery()
{ 
	set statement = ##class(%SQL.Statement).%New()
	set statement.%ObjectSelectMode=1
	set tSC = statement.%PrepareClassQuery("Learning.DB.NewClass1","GetAddressQuery",0)
	set tResult = statement.%Execute()
	do tResult.%Next()
	write !,"MyObjPrope :",tResult.%Get("Address"),"  object:",$isobject(tResult.%Get("Address"))
	quit
}

Query GetAddressQuery() As %SQLQuery(ROWSPEC = "Address") [ SqlProc ]
{
	SELECT Address FROM Samples_DB.NewClass1 Where Id=3
}


}
Product version: IRIS 2023.2
$ZV: IRIS for Windows (x86-64) 2023.2
Discussion (3)2
Log in or sign up to continue