Using Dictionary Handle
A dictionary handle is required in order to access data in a database. The dictionary contains schema definitions for the database. In contrast to relational databases, dictionary and database are separated, i.e. one may create any number of databases referring to the same dictionary.
A dictionary handle is a database handle, which allows accessing dictionary resources using the same means as for accessing a database. Names and meaning of dictionary resources are described in detail in the "ODABA Model reference" section in "Reference documentation").
... fragment ( ) {
Dictionary dict;
dict.open("Sample.dev");
Property types(dict,"SDB_Type",Read);
Value name(types,"sys_ident");
Value number(types,"itype");
while ( types.next() )
printf("%s(%s)\n",name.toString(),number.toString());
}
The application dictionary contains schema definitions for the database and resources for running the application (functions, forms, document templates etc).
After opening the dictionary handle, dictionary resources are cached within the internal dictionary and might be accessed by metadata access class functions ("Reference documentation / ODABA application interface / Metadata classes"). The dictionary is required for opening the database handle.
Typically, dictionaries are opened for read-only access with shared (multiple) use. In order to update dictionary resources, one may, however, open a dictionary also for write access.
... fragment ( ) {
Dictionary dict;
Database db;
dict.open("Sample.dev", Read, true);
db.open(dict, "Sample.dat");
// ... do something
}
In order to access system resources, i.e. resources, which are used to store schema definitions, each dictionary can be seen as database relatively to another dictionary, which is the system dictionary. The system dictionary defines the schema for a dictionary.
The system dictionary cannot be accessed as database, since it contains internal resource definitions, only. Nevertheless, the system dictionary is a dictionary and one may call metadata class functions in order to access type definitions in the system dictionary.
The system dictionary is opened when starting up the application as an application resource. The system dictionary can be accessed by calling Application ::systemDictionary() .
In order to open an extended system dictionary providing schema definitions far GUI resources, ode.sys or another external dictionary might be defined in the SYSTEM] section in the configuration or ini-file as system dictionary extension. This allows you to define your own resource extensions, which one may store in the application dictionary (resource database) and refer to in your application.
... fragment ( ) {
Dictionary dict(Application::systemDictionary());
TypeDefinition td(dict.typeDefinition("SDB_Structure"));
// .. now, you may display type properties for SDB_Structure
}
In order to open a dictionary on the server, the main client or the client passed to the dictionary constructor has to be connected to a server. A server dictionary is required when a database is going to be accessed via server.
The dictionary location is, usually, passed as option variable, which is looked up in the servers file catalog. When the server location for the dictionary is known, one may also pass the dictionary file path explicitly.
For being more scalable, the dictionary might be configured within the data source in a configuration or ini-file.
Dictionary openDictionary ( ) {
Client client;
Dictionary dict;
client.Connect("my_server", 6123);
dict.open(client, "%SAMPLE_DICT%", Read, true);
return dict;
}