Cache class Program
I get a input from user.How to I retrieve the data from these input. I enter the program but its occurred Some error .So give an idea of how to retrieve the data from properties.
ClassMethod Getvalue()
{
S Details = ##class(Sample.Employeedetails).%New()
r "Enter Your Name:" , Name1
s Details.Name = Name1
r "Enter Your Address :", Address1
s Details.Address = Address1
r "Enter your Phone Number:",Phonenumber1
s Details.Phonenumber = Phonenumber1
r "Enter your Blood Group:", Bloodgroup1
s Details.Bloodgroup = Bloodgroup1
r "Enter Your Desination:",Desiation1
s Details.Desination = Desiation1
r "Enter your Domain :",Domain1
s Details.Domain = Domain1
s status = Details.%Save()
}
ClassMethod PrintDetails()
{
W ##class(Sample.Employeedetails).#Name
}
You should actually read this tutorial.
Every class, has some types of elements, and some of them like Property and Parameter may contains some data.
Property stores data for every objects in this class, Parameter, for class itself.
In your example, saving data to properties of object was right. But in method PrintDetails, you try to read data from Parameter, not from property. To read data from property you should open this object before, but you also need to know an ID for such object.
Thanks. We retrieved individual data in a property. Is not possible to retrieve the whole data in a property?
What does you mean ? In this case we get all data in property Name, if you need data from other property just use it.
set obj.name = name1,name2,name3
Is possible I retrieve the all data in same properties without Id?
in your code,
obj - it is some object, it may have some ID or not, if it just created
name1 - it is a value for property name in that object
but I completely don't understand why is here name2 and name3, and what do you suppose should be happens after this line ?
and how it should save data in other objects which we even don't know which ?
you should know somehow which objects you want to update. If you know only some other properties, you can use SQL command UPDATE
What do you want to do with it?
If you want to pull data out of multiple instances of the same class that have been previously stored, you will need to either get them 1 by 1 using object ids or you will need to do some sort of SQL query or result set type routine.
%SQL.Statement documentation may be helpful for you if you need to dynamically generate queries.