Fetching results from parameterized statement in C++ libneo4j_client

47 views Asked by At

This is a follow up question regarding fetching the data from a parameterized query. Consider the following code:

const char *neo4j_query = "MATCH (p:Person) WHERE p.age > {age} RETURN p.name AS name, p.age as AGE";
neo4j_map_entry_t map_entry = neo4j_map_entry("age", 28);
neo4j_value_t params = neo4j_map(&map_entry, 1);
neo4j_run(session, q, params);

When I try to fetch the data using:

neo4j_result_stream_t *results = neo4j_run( session, neo4j_query, params);
if (results == NULL)
{
    neo4j_perror(stderr, errno, "Failed to run statement");
    printf( "%s\t%s\n", move_details->move, neo4j_query);
    return EXIT_FAILURE;
}

neo4j_result_t *result = neo4j_fetch_next(results);
if (result == NULL)
{
    neo4j_perror(stderr, errno, "Failed to fetch result");
    return EXIT_FAILURE;
}

I get the following message

Failed to fetch result: Success

Question is if there is any special way to fetch results?

1

There are 1 answers

0
Chris Leishman On

According to the documentation, a NULL returned from neo4j_fetch_next(...) means there were no (more) results in the stream - so perhaps the query has no results?