From 4e665718a15c143b8513a135dee7e90a45bbd260 Mon Sep 17 00:00:00 2001 From: Arunabh Das Date: Thu, 27 Apr 2023 05:09:59 +0800 Subject: [PATCH] Add initial CALL Clause documentation --- docs/clauses/call.md | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 docs/clauses/call.md diff --git a/docs/clauses/call.md b/docs/clauses/call.md new file mode 100644 index 000000000..e9359384a --- /dev/null +++ b/docs/clauses/call.md @@ -0,0 +1,84 @@ +# CALL + +The CALL clause is used to invoke a built-in or a user-defined function. + +## CALL ... YIELD + +The basic syntax for the CALL ... YIELD clause is as follows: + +```postgresql +CALL functionName(arg1, arg2, ..., argn) YIELD functionName +``` + +Where `functionName` is the name of the stored or user-defined function to be called. +`arg1`, `arg2`, ..., `argn` are the arguments to be passed to the procedure or function. + +Some examples of how to use the CALL clause: + +## Call a Built-in Function + +```postgresql +SELECT * +FROM cypher('graph_name', $$ + CALL toInteger('1') YIELD toInteger AS int + RETURN int +$$) as (c agtype); +``` + + + + + + + + + + + +
c
1
(1 row)
+ +This example calls the `toInteger()` built-in function to yield the string as an integer. + +## Match then Call a Built-in Function + +```postgresql +SELECT * +FROM cypher('graph_name', $$ + MATCH (v) + CALL label(v) YIELD labels AS l_v + CALL properties(v) YIELD properties AS p_v + RETURN l_v, p_v +$$) as (labels agtype, props agtype); +``` + + + + + + + + + + + + + + + + + + + + + +
labelsprops
"Person"{"name": "Wes"}
"Person"{"name": "Doe"}
"Person"{"name": "Cruz"}
(3 rows)
+ +This example calls the built-in functions `label()` & `properties()` to retrieve the labels & properties of the matched vertices. + +## Calling a User-Defined Function + +```postgresql +CALL myFunc("AGE", "Graph Database") YIELD myFunc +``` + +This example calls a user-defined function named `myFunc` and passes the arguments `"AGE"` and `"GRAPH DATABASE"` to the function. \ No newline at end of file