P34K1N opened a new issue, #2225:
URL: https://github.com/apache/age/issues/2225

   Hello, I'm trying to use AGE's prepared statement to bulk insert data in my 
graph. To work with my Postgres database I use standard golang sql package. My 
code looks like this:
   
   ```go
   data := "<some data as serialized JSON>"
   
   query := `SELECT *
   FROM cypher('service_graph', $$
        <some code>
   $$, $1)
   AS (v agtype);`
   
   stmt, err := conn.PrepareContext(ctx, query)
   if err != nil {
        return fmt.Errorf("error on preparing statement: %w", err)
   }
   
   _, err = stmt.ExecContext(ctx, data)
   if err != nil {
        return fmt.Errorf("error on executing statement: %w", err)
   }
   
   err = stmt.Close()
   if err != nil {
        return fmt.Errorf("error on closing statement: %w", err)
   }
   ```
   
   If I execute this code I get the following error:
   `ERROR: invalid input syntax for type agtype (SQLSTATE 22P02)`
   
   If I try to cast $1 to agtype in any way (for example, 
`$1::varchar::agtype`) I get this:
   `ERROR: third argument of cypher function must be a parameter (SQLSTATE 
22023)`
   
   So I need to somehow pass my argument in a way that makes PG recognize it as 
agtype without any typecasting. How do I do this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to