Creating and updating objects with the OQL interpreter

Once a schema has been created in the database, we can create and update Person and Employee instances.

Using the eyedboql monitor, we are going to perform the following operations:

Here is the way to perform the first three step:

% eyedboql -d foo -w
Welcome to eyedboql.
  Type `\help' to display the command list.
  Type `\copyright' to display the copyright.
? john := Person(firstname : "john", lastname : "wayne", age : 72);
= 2585.2.196439:oid
? mary := Person(firstname : "mary", lastname : "poppins", age : 68);
= 2587.2.702511:oid
? john.spouse := mary;
= 2587.2.702511:oid

Note the -w option on the eyedboql command line, specifying that you open the foo database in write mode.

A few comments:

To create the three "john wayne" children:

? add Person(firstname : "baby1", age : 2) to john->children;
= 2589.2.36448:oid
? add Person(firstname : "baby2", age : 3) to john->children;
= 2595.2.683802:oid
? add Person(firstname : "baby3", age : 4) to john->children;
= 2597.2.134950:oid

At this stage, it is interesting to perform the following operation: in another terminal, launch another eyedboql command on the same database foo and query all persons, as follows:

% eyedboql -d foo -w -c "select Person;"
= bag()

It may seem surprising that no person instance is returned, but in fact it is not: each interaction with the database occurs within a transaction, and as long as this transaction has not been committed, the database is not modified by the operations that have been done since the beginning of the transaction. To perform effectively these operations, you must commit the transaction, by typing in the first eyedboql session:

? \commit

If you now query the person instances in your second eyedboql session, the five person instances will be returned:

? eyedboql -d foo -w -c "select Person;"
= bag(2597.2.134950:oid, 2595.2.683802:oid, 2589.2.36448:oid, 2587.2.702511:oid, 2585.2.196439:oid)

You can now quit the first eyedboql session with the following command:

? \quit