Coder Social home page Coder Social logo

Apply bind variable to cypher about age HOT 4 CLOSED

kysmou avatar kysmou commented on September 13, 2024
Apply bind variable to cypher

from age.

Comments (4)

pdpotter avatar pdpotter commented on September 13, 2024

From #43 (comment):

The format $1 is the Postgres format for parameters and cannot be used in the cypher query. Parameters in the cypher query must take the format $parameter_name. When you want to pass parameters to a cypher query, you must add a third argument to the cypher query. This argument must be a Postgres parameter. So your query must look like:

SELECT * FROM cypher('testgraph', $$CREATE (v:Person {name: $var_name})$$, $1) as (a agtype);

When executing the query the value passed to $1 must be an agtype map, where the key is the variable name. NOTE: All parameters in the cypher query are passed in the map.

For more information, see the section Prepared Statements in the AGE Guide (PDF).

from age.

kysmou avatar kysmou commented on September 13, 2024

Thank you for your response.
I will check it by referring to the manual again. Thank you so much.

from age.

kysmou avatar kysmou commented on September 13, 2024

To test the prepared statement, I tested it by referring to the manual.
However, the following error occurs, but if there is something I am doing wrong, please tell me. This is the age 0.4.0 version.

PREPARE cypher_stored_procedure(agtype) AS
SELECT *
FROM cypher('test_graph', $$
MATCH (v:Person)
WHERE v.name = $name
RETURN v
$$, $1)
AS (v agtype);

execute cypher_prepared_statement('{"name":"affeee"}');
ERROR: prepared statement "cypher_prepared_statement" does not exist
STATEMENT: execute cypher_prepared_statement('{"name":"affeee"}');
prepared statement "cypher_prepared_statement" does not exist

from age.

JoshInnis avatar JoshInnis commented on September 13, 2024

In the second example, the prepared statement is called "cypher_stored_procedure" and the execute is for the prepared statement "cypher_prepared_statement."

from age.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.