Project

General

Profile

Actions

Insert

Inserts statements into a model. Specify the statements either explicitly or by using a select command. The corresponding command for deleting statements is delete.

To insert a single statement, specify its subject, predicate and object after the insert command. For example:

insert <ns:subject> <ns:predicate> 'object' into <rmi://mysite.com/server1#model>;

To insert multiple statements, repeat the statements one after the other. For example:
insert <ns:subject> <ns:predicate> 'object'
<ns:subject2> <ns:predicate2> 'object2' into <rmi://mysite.com/server1#model>;

Note: Inserting multiple statements using a single insert command provides optimal performance when working over a network.

Blank (anonymous) nodes are inserted using unbound variables. For example:

insert <ns:subject> <ns:predicate> $node
$node <ns:predicate2> 'object2' into <rmi://mysite.com/server1#model> ;

Where $node becomes an anonymous node at execution time.

An alternative way to insert a group of statements is to include a select command after the insert command. The query must select exactly three columns, corresponding to the subject, predicate and object (in that order) of the statements to be added.

The following example selects all the statements in #model1 and uses the result within an insert command to copy all the statements in #model1 to another model, #model2.

insert select $s $p $o from <rmi://mysite.com/server1#model1>
where $s $p $o into <rmi://mysite.com/server1#model2>;

Note: The query must return valid RDF statements. That is, the subject and predicate must be resources, not literals.

Updated by Paula Gearon over 15 years ago ยท 2 revisions