29.2.2.1 Loading Datetime Data
You must first load a graph to work with datetime data. See Reading Graphs from Database into the Graph Server (PGX) for more information on graph loading.
The following example shows how to load a graph that has three vertices representing persons and zero edges.
- Create a SQL property graph using datetime data stored in
emptable as shown:CREATE TABLE emp ( id NUMBER (10) NOT NULL name VARCHAR2(10), j joined_on TIMESTAMP, CONSTRAINT emp_pk PRIMARY KEY (id) ); INSERT into emp values (100, "John", to_timestamp('1990-02-02 09:30:00', 'YYYY-MM-DD HH:MI:SS'); INSERT into emp values (200, "Mary", to_timestamp('2000-07-01 10:15:20', 'YYYY-MM-DD HH:MI:SS'); INSERT into emp values (300, "Alice", to_timestamp('2014-10-10 11:00:00', 'YYYY-MM-DD HH:MI:SS'); CREATE PROPERTY GRAPH emp_graph VERTEX TABLES ( emp KEY ( id ) LABEL emp PROPERTIES ( id, name, joined_on ) ); -
Load the graph into the graph server (PGX) and optionally, query the graph.
opg4j> var g = session.readGraphByName ("EMP_GRAPH",GraphSource.PG_SQL)
opg4j> g.queryPgql("SELECT n.* FROM MATCH (n)").print()
+-----------------------------------+
| ID | NAME | JOINED_ON |
+-----------------------------------+
| 200 | Mary | 2000-07-01T10:15:20 |
| 100 | John | 1990-02-02T09:30 |
| 300 | Alice | 2014-10-10T11:00 |
+-----------------------------------+
$3 ==> PgqlResultSetImpl[graph=EMP_GRAPH,numResults=3]PgxGraph g = session.readGraphByName("EMP_GRAPH", GraphSource.PG_SQL);
PgqlResultSet resultSet = g.queryPgql("SELECT n.* FROM MATCH (n)");
resultSet.print();>>> g = session.read_graph_by_name("EMP_GRAPH", "pg_sql")
>>> g = session.read_graph_by_name("EMP_GRAPH", "pg_sql")
+-----------------------------------+
| ID | NAME | JOINED_ON |
+-----------------------------------+
| 200 | Mary | 2000-07-01T10:15:20 |
| 100 | John | 1990-02-02T09:30 |
| 300 | Alice | 2014-10-10T11:00 |
+-----------------------------------+Parent topic: Using Datetime Data Types