Question Hour Abdellatif · Jan 26

Can globals exist without SQL access?

Hello everyone,

My team lead mentioned that users can sometimes create globals directly without associating them with tables or classes. In this case, these globals would not be accessible via SQL.

Is this correct? Can a global exist independently in this way, and if so, is there a specific approach to access or manage them without SQL?

Product version: Caché 2018.1

Comments

DC AI Bot · Jan 26 Bot

Yes, globals can exist independently without any association with SQL tables or classes, and in such situations, they wouldn't be accessible via SQL. Globals are a unique storage structure in InterSystems IRIS, serving as persistent multidimensional sparse arrays. These can be directly manipulated with ObjectScript or other programming languages compatible with IRIS, allowing the creation of custom data structures not adhering to relational or object models. Without SQL integration or object class mapping, such globals are strictly managed at the global level [1][2].

Sources:

0
Rob Tweed  Feb 5 to DC AI Bot

Just a small correction - Globals aren't unique to IRIS.  There are other databases that use them out there. Search for M or Mumps databases to find out more. 
 

0
David Hockenbroch · Jan 26

Yes. You can use a variable name starting with ^, like ^MyGlobal, and it will be a global. You will not be able to access it via SQL, but you will be able to see it with the globals in the system management portal. You can also reference globals in a different namespace by using ^|"namespace"|MyGlobal.

0
Gabriel Ing · Jan 26

Globals can be defined and accessed directly using a caret (^) symbol. For example, you can set or access a global with: 

// define a global by setting a value
set ^GlobalName = "Hello World"
// Access different sub-nodes 
set ^GlobalName(1, "foo") = "bar"
// You access the global in a similar way
write ^GlobalName // prints Hello World
// write all global values
zwrite ^GlobalName
// ^GlobalName = "Hello World"
// ^GlobalName(1,"foo") = "bar"

This can be useful for quickly saving values globally or looking up values.

I recommend having a look at the Using Caché Globals section of the Cache documentation because it has far more information on globals usage than could be relayed in a comment. 

0
Tim Huggins · Jan 26

They can exist without SQL access but you can always make them available through SQL at a later date by mapping a class to them.

0
Joel Solon  Feb 3 to Tim Huggins

and by "always" Tim means: "in some cases with a only little bit of work, but sometimes with a large amount of work"

Right, Tim?

0
Tim Huggins  Feb 4 to Joel Solon

True. And it depends on how logically the globals were set up in the first place as to whether the mapped tables/classes can reflect a sensible logical schema. You could still map them without that but it wouldn't be great for usability.

0

Yes, a global exists without SQL association. If you want to associate an SQL definition you should map it to SQL

0