Home    |    Concepts   |   API   |   Samples
Concepts > Versioning > SQL Access using Multi-Version Views
Executing SQL Queries

Using the example used in the topic Version, which had versions WORKING, EDIT1, and EDIT2, rows in the current WORKING version will be selected using the following SQL expression:

EXECUTE set_current_version ('WORKING');
SELECT OID, DATA FROM ExampleTable;
 
At Time T=1,
the results of this query will be:

OID Data
100 aa
101 b
At Time T=4,
the results of this query will be:
OID Data
100 <deleted>
101 bbb
102 c
At Time T=5,
the results of this query will be:
OID Data
100 a
101 bbb
102 C
103 d

If you want to restrict this query to only Data = b, the query looks like this:

EXECUTE set_current_version ('WORKING');
SELECT OID, Data FROM ExampleTable WHERE Data = "b"

The results of this query will be:

OID Data
101 b

Executing inserts

Inserting a row into version EDIT2 with a data value of www, the multiversioned view automatically assigns the object ID. The following SQL code could be used:

EXECUTE set_current_version ('EDIT2');

EXECUTE edit_version ('EDIT2',1);

INSERT INTO ExampleTable (Data) VALUES ("www");

EXECUTE edit_version ('EDIT2',2);

Executing deletes

To delete a row with an OID of 102 from version EDIT2, the following SQL code could be used:

EXECUTE set_current_version ('EDIT2');

EXECUTE edit_version ('EDIT2',1);

DELETE FROM ExampleTable WHERE OID = 102;

EXECUTE edit_version ('EDIT2',2);

Executing updates

To update a row with an OID of 102 in version EDIT2, changing the value www in the column Data to yyy, the following SQL code could be used:

EXECUTE set_current_version ('EDIT2');

EXECUTE edit_version ('EDIT2',1)

UPDATE ExampleTable SET Data = 'yyy' WHERE OID = 102

EXECUTE edit_version ('EDIT2',2)
feedback | privacy | legal