YMatrix
Quick Start
Connecting
Benchmarks
Deployment
Data Usage
Manage Clusters
Upgrade
Global Maintenance
Expansion
Monitoring
Security
Best Practice
Technical Principles
Data Type
Storage Engine
Execution Engine
Streaming Engine(Domino)
MARS3 Index
Extension
Advanced Features
Advanced Query
Federal Query
Grafana
Backup and Restore
Disaster Recovery
Graph Database
Introduction
Clauses
Functions
Advanced
Guide
Performance Tuning
Troubleshooting
Tools
Configuration Parameters
SQL Reference
Cypher can execute read-only queries within prepared statements. When using parameters with stored procedures, a SQL parameter must be passed to the Cypher function call. For details, see Cypher Query Format.
A Cypher parameter has the form $ followed by an identifier. Unlike PostgreSQL parameters, Cypher parameters must begin with a letter and may be followed by any alphanumeric string.
Example: $parameter_name
Preparing a Cypher statement is an extension of the PostgreSQL stored procedure system. Use the PREPARE command to define a query containing a Cypher function call. Do not use PostgreSQL-style positional parameters (e.g., $1) inside the Cypher query string. Instead, use Cypher parameters (e.g., $name) in the Cypher query, and pass the corresponding PostgreSQL parameter as the third argument to the cypher() function.
PREPARE cypher_stored_procedure(agtype) AS
SELECT *
FROM cypher('expr', $$
MATCH (v:Person)
WHERE v.name = $name // Cypher parameter
RETURN v
$$, $1) // SQL parameter must be passed as the third argument to cypher()
AS (v agtype);
When executing the prepared statement, supply an agtype map containing the parameter values at the position of the SQL parameter in the cypher() call. The value must be a valid agtype map; otherwise, an error is raised. Parameter names in the map omit the leading $.
EXECUTE cypher_stored_procedure('{"name": "Tobias"}');