Manipulating objects using OQL

The OQL interpreter can be used to manipulate object, for instance updating the attributes of objects returned by a query.

First, launch an eyedboql session as in:

% eyedboql -d foo -w
Welcome to eyedboql.
  Type `\help' to display the command list.
  Type `\copyright' to display the copyright.
	

The database must be opened in write mode, because we are going to modify the objects stored in the database.

To change the lastname attribute of the person whose firstname is mary:

? (select Person.firstname = "mary").lastname := "stuart";
= bag("stuart")
	  

To increment the age attribute of all persons, we use a for loop to iterate on the result of a query:

? select Person.age;
= bag(4, 3, 2, 68, 72)
? for (p in (select Person)) { p.age += 1 ; };
? select Person.age;
= bag(5, 4, 3, 69, 73)