6.8.6.2 Executing UPDATE Queries against a Graph in the in-memory Graph Server (PGX)
To execute UPDATE
queries against a graph, use the
PgxGraph.executePgql(String query)
method.
The following is an example of
INSERT
query:
g.executePgql("INSERT VERTEX v " +
" LABELS ( Person ) " +
" PROPERTIES ( v.firstName = 'Camille', " +
" v.lastName = ' Mullins' ) ");
Note that the INTO
clause of
the INSERT
can be omitted. If you use an INTO
clause, the
graph name in the INTO
clause must correspond to the name of the PGX graph
(PgxGraph.getName()
) that the query is executed against.
The following is an example of
UPDATE
query:
// set the date of birth of Camille to 2014-11-15
g.executePgql("UPDATE v SET ( v.dob = DATE '2014-11-14' ) " +
"FROM MATCH (v:Person) " +
"WHERE v.firstName = 'Camille' AND v.lastName = ' Mullins' ");
The following is an example of
DELETE
query:
// delete Camille from the graph
g.executePgql("DELETE v " +
"FROM MATCH (v:Person) " +
"WHERE v.firstName = 'Camille' AND v.lastName = 'Mullins' ");
Parent topic: Java APIs for Executing UPDATE Queries