How to get values from a serialobject class
Hi,
I
want to get the values from a serial property because my code depends upon the class serial class.
For example
Serial class
Class Data.Serial Extends %SerialObject
{
Property FirstName as %String;
Property LastName as %String;
}
Persistent class
Class Data.Persistent Extends %Persistent
{
Property MPID as %Integer;
Property Name as Name.Serial;
}
Now i need save MPID and Name(Serial class property into SQL Table ) so i am trying the below class
Class Data.TestUtil Extends
{
Method Savedata(MPID,FirstName,LastName)
{
Set tSC=0
Set Obj=##Class(Data.Persistent).%New()
Set Obj.MPID=MPID
Set Obj.FirstName=FirstName
Set Obj.LastName=LastName
Set tSC=Obj.%Save()
Quit tSC
}
}
But data is not getting saved into SQL data and throwing an error, How to save serial class Property into the SQL table?
Thanks,
Smythee
If your serial class is named Data.Serial (as in your example code) then you should use the same name for the serial property too
Class Data.Persistent Extends %Persistent { Property MPID as %Integer; Property Name as Data.Serial; <--- !!!!! }
The correct way to set the values
Set Obj=##Class(Data.Persistent).%New() Set Obj.MPID=MPID Set Obj.Name.FirstName=FirstName ; <---- Set Obj.Name.LastName=LastName ; <---- Set tSC=Obj.%Save()
Hi ,
I gave the example of the scenario i am using in my code but i am getting Invalid Oref error
"
ERROR <Ens>ErrException: <INVALID OREF>zDischarge+3^CUSTOM.SQL.TestUtil.1 -- logged as '-' number - @' Set Obj.Discharge.DischargeFlag=DischargeFlag'"