Discussion (9)0
Log in or sign up to continue

Both plus globals.

NoSQL:

set obj = ##class(Sample.Person).%New()
set obj.Name = "John"
set obj.Spouse = #class(Sample.Person).%OpenId(1) // Let's assume it's a woman.

set sc = obj.%Save() // Use sc to know if any error happened.


SQL:

set s = ##class(%SQL.Statement).%New()
set sc = s.%Prepare("INSERT INTO Package.PersistentClass (property) VALUES (propertyValue)")
set sc = s.%Execute() // If everything is OK sc is 1, otherwise you might want to check s.%Message and s.%SQLCODE as well.


You can also use embedded SQL, search for "&sql" on the link I provided.

Globals

WARNING: I don't recommend any manipulation using globals directly if you 're working with classes.

Normally class globals are stored following the pattern below:

^Package.ClassNameI for index
^Package.ClassNameD for values
^Package.ClassNameS for streams

Check the class's Storage XML discover it's global structure.

Hi, Arockia!

InterSystems Caché is multi-model DBMS - see the official information. Caché comes with 3 models "out-of-the box": Globals, SQL, Caché Objects.

Everything in Caché is stored in Globals, which are multidimensional key-value indexed variables with persistent nature.  The good visible explanation of "what is global" you can find in this Merge command article, or in @Rob Tweed's article.

"Multi-model" means that:

- you can store data in the same database with different data models simultaneously.

- you can access the same data via different data engines if the data models are compatible: e.g.  you can operate with same data via Caché SQL, Caché Objects and Globals because they are compatible. Need to notice, that if you want to access globals, which are part of storage schema for Caché Objects and SQL it is safe to access only for read manipulations(or you should be very confident in what are you doing). For other types of manipulation better use documented model-related functions.

- you can use the data models which come "out-of-the box" (Globals, SQL, Caché Objects) and you can implement your own data-manipulation library with Caché ObjectScipt or bindable languages which would store the data in Globals in your own way, structure and logic. Using this approach you can implement literally any data model e.g. graph, document store, key-value, your-own-unique-extraordinary-database-model, but you would be responsible for the  support as well ;)

Hope that helps.