company logo

Common properties on instance level (meta attributes)

Beside properties defined in the data model, ODABA supports several instance properties (meta attributes), which are available via instance descriptors maintained by ODABA for each instance or which provide derived information from the instance. Those meta attributes can be retrieved by property functions, too, but sometimes it is more comfortable accessing them via property names, e.g. when using them as data source in the designer.

This feature is supported for convenience, but it is suggested to refer to appropriate functions for providing meta attributes.

__IDENTITY, __LOID

Each object instance stored in the database contains the local unique identifier for the instance, which is provided passing this attribute. The value can also be provided calling the loid() function.

  Property      persons(obh,"Persons",PI_Read);

  Value         p_loid(persons,"__LOID");

  int64         loid;

  

  persons.get("00001");

  loid = persons.loid();  // same as: p_loid.toBig()

__GUID

The property contains the global unique identifier for an instance. GUIDs are supported for instances, only, which inherit from the __OBJECT data type. In order to create a global unique identity for instances in a collection, the structure definition in the data model must have switched the guid option on. Moreover, the guid option must be set for the collection owning the instance.

When the instance is not equipped with global identifiers the local identifier (LOID) within the database is returned as global identifier. Global identifiers differ from local once syntactically, since they begin with an one digit GUID version number and a dash, always (e.g. '1-...').

Global identifiers can be read by calling the guid() function or by defining a value handle for the instance property __GUID.

  Property      person(obh,"Persons",PI_Read);

  Value         p_guid(persons,"__GUID");

  String        guid;

  

  persons.get("00001");

  guid = person.guid();  // same as:  p_guid.toString()

__SORTKEY, __SORTKEY_STRING

Instead of reading the access key by calling accessKey(), one may refer to the __SORTKEY_STRING instance property. The key can be used for displaying or locating an instance in the collection.

In contrast to key functions, which return a Key object, the instance property just returns a string and does not provide meta information for the key.

Used with the ODABA API, both properties return a key string. In the system API, however, __SORTKEY returns the internal key, while __SORTKEY_STRING returns the key value converted into string format.

  Property      person(obh,"Persons",PI_Read);

  Value         p_sortkey(persons,"__SORTKEY_STRIN");

  Key           sortkey;

  

  persons.get(0);

  key = person.accessKey();  // same as: p_sortkey.toString()

__TYPE

The type property may change also for instances in a collection (weak-typed or untyped collections). In order to obtain the type of the currently selected instance, one may refer to the __TYPE property or call the currentType() function.

  Property      person(obh,"Persons",PI_Read);

  Value         p_type(person,"__Type");

  String        typeName;

  

  person.get(0);

  key = person.currentTypeDefinition().name();  // same as: p_type.toString()

Enumerator attributes

When referring to enumerated attributes within a complex data type or as variable (e.g. within an OSI function), enumerator attributes may be provided for the enumerator value currently set in the attribute.

  • code - the numerical enumerator value as being stored in the enumerator attribute
  • name - the enumerator name as being used in programs
  • label - language depending enumerator name
  • title - language depending short description
  • description - detailed language depending description of the enumerator value (html)
  • condition - condition or default value associated with the category
  • type - data type associated with the category

Language depending attributes are provided according to the language set in option DSC_Language. Since enumerator definitions are part of the dictionary, language cannot be changes while running the application.

// OSI - obtain from enum value

... fragment ( Languge my_lang ) { my_lang contains an enum-value

  Message(my_lang.name);       // display enumerator name

  Message(my_lang.label);      // display enumerator label

  if ( !my_lang.condition.isEmpty() )

    Message(my_lang.condition);// display condition

}

Notes:

Internally, enumerator attributes are odaba::String (except code, which is numeric). Hence, within OSI functions one cannot apply operators on enumerator attributes, but odaba::String functions, only.