You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by Plamen Paskov <pl...@next-stream.com> on 2016/04/14 15:12:41 UTC

prepareAndExecute with UPSERT not working

Hey folks,
I'm trying to UPSERT some data via the json api but no luck for now. My 
requests looks like:

{
   "request": "openConnection",
   "connectionId": "6"
}

{
   "request": "createStatement",
   "connectionId": "6"
}

{
   "request": "prepareAndExecute",
   "connectionId": "6",
   "statementId": 9,
   "sql": "UPSERT INTO us_population VALUES('IL','Chicago',10000000)",
   "maxRowCount": -1
}

The response for prepareAndExecute looks like the operation is 
successful but i don't see the new data added to the table.

{
   "response": "executeResults",
   "missingStatement": false,
   "rpcMetadata": {
     "response": "rpcMetadata",
     "serverAddress": "ip-172-31-27-198:8765"
   },
   "results": [
     {
       "response": "resultSet",
       "connectionId": "6",
       "statementId": 9,
       "ownStatement": false,
       "signature": null,
       "firstFrame": null,
       "updateCount": 1,
       "rpcMetadata": {
         "response": "rpcMetadata",
         "serverAddress": "ip-172-31-27-198:8765"
       }
     }
   ]
}

Any ideas?
Thanks in advance!

Re: prepareAndExecute with UPSERT not working

Posted by Steve Terrell <st...@oculus360.us>.
I found it much easier and reliable to make my own phoenix HTTP server with
my own JSON API.  It was too confusing for me to send multiple requests for
what would normally be just one SQL statement.  And I had problems getting
upserts working, to boot (even with the thin server).  Now I can make the
API as simple as I like.  I am using Phoenix 4.6.0.

Good luck,
    Steve

On Thu, Apr 14, 2016 at 8:12 AM, Plamen Paskov <
plamen.paskov@next-stream.com> wrote:

> Hey folks,
> I'm trying to UPSERT some data via the json api but no luck for now. My
> requests looks like:
>
> {
>   "request": "openConnection",
>   "connectionId": "6"
> }
>
> {
>   "request": "createStatement",
>   "connectionId": "6"
> }
>
> {
>   "request": "prepareAndExecute",
>   "connectionId": "6",
>   "statementId": 9,
>   "sql": "UPSERT INTO us_population VALUES('IL','Chicago',10000000)",
>   "maxRowCount": -1
> }
>
> The response for prepareAndExecute looks like the operation is successful
> but i don't see the new data added to the table.
>
> {
>   "response": "executeResults",
>   "missingStatement": false,
>   "rpcMetadata": {
>     "response": "rpcMetadata",
>     "serverAddress": "ip-172-31-27-198:8765"
>   },
>   "results": [
>     {
>       "response": "resultSet",
>       "connectionId": "6",
>       "statementId": 9,
>       "ownStatement": false,
>       "signature": null,
>       "firstFrame": null,
>       "updateCount": 1,
>       "rpcMetadata": {
>         "response": "rpcMetadata",
>         "serverAddress": "ip-172-31-27-198:8765"
>       }
>     }
>   ]
> }
>
> Any ideas?
> Thanks in advance!
>

Re: prepareAndExecute with UPSERT not working

Posted by Josh Elser <jo...@gmail.com>.
What version of Phoenix are you using?

Plamen Paskov wrote:
> Hey folks,
> I'm trying to UPSERT some data via the json api but no luck for now. My
> requests looks like:
>
> {
> "request": "openConnection",
> "connectionId": "6"
> }
>
> {
> "request": "createStatement",
> "connectionId": "6"
> }
>
> {
> "request": "prepareAndExecute",
> "connectionId": "6",
> "statementId": 9,
> "sql": "UPSERT INTO us_population VALUES('IL','Chicago',10000000)",
> "maxRowCount": -1
> }
>
> The response for prepareAndExecute looks like the operation is
> successful but i don't see the new data added to the table.
>
> {
> "response": "executeResults",
> "missingStatement": false,
> "rpcMetadata": {
> "response": "rpcMetadata",
> "serverAddress": "ip-172-31-27-198:8765"
> },
> "results": [
> {
> "response": "resultSet",
> "connectionId": "6",
> "statementId": 9,
> "ownStatement": false,
> "signature": null,
> "firstFrame": null,
> "updateCount": 1,
> "rpcMetadata": {
> "response": "rpcMetadata",
> "serverAddress": "ip-172-31-27-198:8765"
> }
> }
> ]
> }
>
> Any ideas?
> Thanks in advance!