Saving a serial object using Result set
Hi Folks,
I created a persistent class as below
Class myclass.DataBase Extends %Persistent
{
Property ID As %String;
Property Skill As list Of myclass.SerialTablelist;
}
and Created another Serial class as
Class myclass.SerialTablelist Extends %SerialObject
{
Property PSkill As %String;
Property OSkill As %String;
}
Now I will save the id as below
do rs.Prepare("Insert into myclass.DataBase(ID)VALUES(?)")
do rs.Execute(ID)
I am facing issue with the AS LIST OF
Could any one guide me how to save the Skill (PSkill ,OSkill ) using resultset (I am able to )
Hi Philip,
The SQL projection of the property Skill of class myclass.DataBase is compounded by 3 $List.
To Insert via SQL use the following statement:
Regards
Cristiano José da Silva
@Cristiano Silva Thanks for your Response.
Since I am refering the property skill "as list of" another serial class ( Property Skill As list Of myclass.SerialTablelist;)
How could we retrive the skill.oskill and skill.pskill value ?
for example through objects we will fetch the value as below
write obj.Skill.GetAt(1).OSkill,!
Use SQL Procedures.
HI @phillip jack,
Like @Eduard Lebedyuk told, the better way is using stored procedures written in COS, but if you want to use only SQL you can try this:
If you change the serial object and add more properties increment the outer $LISTGET last parameter
Regards,
Cristiano José da Silva.
Many Thanks !! @Cristiano Silva @Eduard Lebedyuk
A little more documentation on the SQL projection of collection properties here.
Currently the
SQLPROJECTION = table
option is only available for "array of" properties. In 2022.1 we intend to make this option also available for "list of" properties.If you're interested, I can dig up a script I wrote a while ago to create a class that projects a read-only view of your "list of" property. No warranty!
@Benjamin De Boe
Thanks for the valuable information
For object properties too?
what do you mean with "for object properties too"? If you're asking whether
projects as a child table; yes it does. (and "list of" will support this too in 2022.1)
If you define Addresses list property like this:
Property Addresses As list Of Sample.Address(SQLPROJECTION = "table/column", STORAGEDEFAULT = "array");
Child table would be created.
you're right. I didn't properly say that with "array of" I actually meant the underlying
STORAGEDEFUALT = "array"
behaviour. So the combination that'll be newly supported in IRIS 2022.1 isSTORAGEDEFAULT = "list"
withSQLPROJECTION = "table"
(and table/column)FWIW, here's my warranty-free code to project list-style collection properties to a table: https://github.com/bdeboe/isc-sql-utils