Evaluate test data
Some examples for accessing data in an ODABA data base via OShell commands and embedded OSI scripts have been provided within the OShell script shown below in the example. The first lines in the script contain OShell script statements for producing simple statistics. The second part contains embedded OSI script in order to provide more complex statistics. Detailed comments to the example you will find in OShell Script comments .
After creating the Sample project, one may simply call OShell.sh (LINUX) or OShell.cmd (Windows), which have been generated to the project's root directory. When generating other projects, the generated scripts have to be revised in order to check file location for the called .osh script file. OShell allows opening data sources defined in a data catalog or in a configuration file passed to the OShell function. The generated configuration file ode.ini contains data source sections for the resource database (e.g. [ Sample_dev ]) and the application database (e.g. [ Sample_dat ]) prefixed with the name of the project created. By default, dictionary and database are expected in the project's root directory. Otherwise, data sources in the ode.ini file have to be updated.
After processing the command passed in the script file, the OShell remains open and the data source is still active. The data collection currently selected is Company . You may enter further OShell commands or q[uit] in order to leave OShell.
cd Sample_dat
cc Company
li
fa p cars.count
fa p employees.count
cc /Employee
count
sf "sex == 'male'"
relativeCount
cc '/Person::Persons'
count
osi do
VARIABLES
int child_count;
int distance = 0, dist = 0;
int min_dist = 100, max_dist = 0;
int dcount = 0;
PROCESS
filter('age > 65 && employee.count == 0');
Message('Persons probably retired (over 65 and not employed): ' + relativeCount);
top();
while ( next() )
child_count += children.count;
Message('Total number of children: ' + child_count);
filter("");
top();
while ( next() )
while ( children.next() ) {
dist = age-children.age;
if ( min_dist >= dist ) min_dist = dist;
if ( max_dist <= dist ) max_dist = dist;
distance += age-children.age;
++dcount;
}
Message('Average age distance between children and parents: ' + distance/dcount);
Message(' Minimum/maximum distance is: ' + (string)min_dist + '/' + (string)max_dist);
end
cc /Company
osi do
VARIABLES
int(10,2) sum_income;
PROCESS
top();
while ( next() ) {
sum_income = 0;
while ( employees.next() )
sum_income += employees.income;
Message('Total income for "' + name + '" is: ' + sum_income);
}
end