This is an automated email from the ASF dual-hosted git repository.

joshinnis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-age-website.git


The following commit(s) were added to refs/heads/master by this push:
     new e9815dd  Added Documentation on how to use SQL in Cypher
e9815dd is described below

commit e9815dd2f0da8ade70dccae4045b19b47d73c15a
Author: Josh Innis <[email protected]>
AuthorDate: Thu Oct 21 12:29:45 2021 -0700

    Added Documentation on how to use SQL in Cypher
---
 docs/advanced/advanced.md      |  4 ++--
 docs/advanced/plpgsql.md       | 12 ++++++++---
 docs/advanced/sql_in_cypher.md | 48 ++++++++++++++++++++++++++++++++++++++++++
 docs/index.rst                 |  2 ++
 4 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/docs/advanced/advanced.md b/docs/advanced/advanced.md
index 56c5672..0c78bd2 100644
--- a/docs/advanced/advanced.md
+++ b/docs/advanced/advanced.md
@@ -1,6 +1,6 @@
 
 
-# CTE Clause
+# Using Cypher in a CTE Expression
 
 There are no restrictions to using Cypher with CTEs. 
 
@@ -55,7 +55,7 @@ Results:
 
 
 
-# Join Clause
+# Using Cypher in a Join expression
 
 A Cypher query can be part of a JOIN clause.
 
diff --git a/docs/advanced/plpgsql.md b/docs/advanced/plpgsql.md
index e018ad5..f486669 100644
--- a/docs/advanced/plpgsql.md
+++ b/docs/advanced/plpgsql.md
@@ -2,11 +2,17 @@
 
 Cypher commands can be run in 
[PL/pgSQL](https://www.postgresql.org/docs/11/plpgsql-overview.html) functions 
without restriction.
 
-## Basic PL/pgSQL
+## Void PL/pgSQL
 
-## Returning scalar data
 
-## Returning SRF data
+
+
+
+## Scalar Function
+
+## SRF Function
 
 ## Dynamic Cypher
 
+
+
diff --git a/docs/advanced/sql_in_cypher.md b/docs/advanced/sql_in_cypher.md
new file mode 100644
index 0000000..8a94fa7
--- /dev/null
+++ b/docs/advanced/sql_in_cypher.md
@@ -0,0 +1,48 @@
+# SQL In Cypher
+
+AGE does not support SQL being directly written in Cypher. However with [user 
defined functions](../functions/user_functions#) you can write sql queries and 
call them in a cypher command.
+
+
+```
+Developer's Note:
+
+Void and Scalar-Value functions only. Set returning functions are not 
currently supported.
+```
+
+
+## Create Function
+```
+CREATE OR REPLACE FUNCTION public.get_event_year(name agtype) RETURNS agtype 
AS $$
+       SELECT year::agtype
+       FROM history AS h
+       WHERE h.event_name = name::text
+       LIMIT 1;
+$$ LANGUAGE sql;
+```
+
+## Query
+```
+SELECT * FROM cypher('graph_name', $$
+       MATCH (e:event)
+       WHERE e.year < public.get_event_year(e.name)
+       RETURN n.name
+$$) as (n agtype);
+
+```
+
+Results
+<table>
+  <tr>
+   <td><strong>name</strong>
+   </td>
+  </tr>
+  <tr>
+   <td>"Apache Con 2021"
+   </td>
+  </tr>
+  <tr>
+   <td colspan="1" >1 row
+   </td>
+  </tr>
+</table>
+
diff --git a/docs/index.rst b/docs/index.rst
index 1d8b7eb..02bd3de 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -52,3 +52,5 @@ Apache AGE's documentation
    advanced/advanced
    advanced/prepared_statements
    advanced/plpgsql
+   advanced/sql_in_cypher
+

Reply via email to