Question
· Feb 2, 2022

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 )

Discussion (12)1
Log in or sign up to continue

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:

SELECT ID, $LISTGET($LISTGET($LISTGET(Skill)),1) PSKILL, $LISTGET($LISTGET($LISTGET(Skill)),2) OSKILL FROM myclass.DataBase
 

If you change the serial object and add more properties increment the outer $LISTGET last parameter

Regards,

Cristiano José da Silva.

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!