Error evaluating filter. - cause: No value for named parameter

n1ql
#1

I am using Couchbase Server 4.5.0-2601 Enterprise Edition (build-2601).
And the following N1QL works fine:

select name from `mydb` where name is not missing and name like "%test%";

it will return the exact value that I want.

Then I create a PREPARE statement by:

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'statement=PREPARE getNameTest FROM select name from `mydb` where name is not missing and name like $name;'

and when I execute the following Query by:

curl -v http://127.0.0.1:8093/query/service -d 'prepared="getNameTest"&$name="%test%"'

It return the following error:

    "errors": [
        {
            "code": 5010,
            "msg": "Error evaluating filter. - cause: No value for named parameter $name."
        }
    ],
    "status": "errors",
#2

Can you try url encoding the second request as well?

#3

It return the same error by send the following request:

curl -v http://127.0.0.1:8093/query/service -d 'prepared=%22getNameTest%22&$name=%22%test%%22'
#4

Try using --data-urlencode.

#5

I try this:

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'prepared=%22getNameTest%22&$name=%22%test%%22'

and this:

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'prepared="getNameTest"&$name="%test%"'

and all return the following errors:

    "errors": [
        {
            "code": 4050,
            "msg": "Unrecognizable prepared statement - cause: Invalid prepared stmt \"\u003cbinary (28 b)\u003e\""
        }
    ],
#6

Ok. On a cluster, you need to pass the encoded plan, because the node might not have the plan. Can you pass the result of PREPARE as the “prepared”. There should be an example in the docs.

#7

I don’t understand.
do you means this docs?
and the following N1QL

select * from system:prepareds where name = "getNameTest";

shows the following results:

[
  {
    "prepareds": {
      "avgElapsedTime": "35.205721ms",
      "avgServiceTime": "35.133186ms",
      "encoded_plan": "H4sIAAAJbogA/5xSwY7aMBT8FcvtgUi0UqWe0hMHkHpoi6C3qiJW/EgeOHbWdtgAyn77vpdlyQJ7WW72eDxvZuyjBJs7DXpVG2VlKuVYWlUBrQqIv2n1F0Ik0NXgVXRepkf5adjIJTw0JAFEecpLNNoDyfy7JE2aWDqPB2b1pLtU5h4r5ffLnIyOJVoNLaE16vaLht33/WFD8Bb2oVY5BxhATjSga9UYjtQEtAUHDSi78dUs5ZUxYM6G7nI8g5iXHzF1bWOGJoLn1pzVGNHxE41Go+wkk33NWCZLBAZhXRQVBk6VCGW1eI9ncAviM2+S5GbcT0szlJl7t4GcK/IQyNaKPFShTwdtzcRbYdn9vzVvBy06ZoasPe7QQAGBGz3lTl9bSb911yrL6EFVvbwMWFgVGw989/RNN4FKobMIbeSHW0znk8VUvPm9Yrb480sEMORD8C2x9q4S5wjisQQPLyeXNfYt9vhQ2w/ZPQcAAP//1n7muzUDAAA=",
      "lastUse": "2016-07-24 13:23:17.714021765 +0800 CST",
      "name": "getNameTest",
      "statement": "PREPARE getNameTest FROM select name from `mydb` where name is not missing and name like $name;",
      "uses": 2
    }
  }
]

So I think the node should have the plan.

#8

Hi @atom_yang,

Try submitting the encoded plan with your second request.

#9

It doesn’t work.
I create a prepared statement by:

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'statement=PREPARE select name from `mydb` where name is not missing and name like $name;'

and Query data by:

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'prepared="6562c30f-293e-449e-813d-2d2939f4da14"&$name="%test%"'

or by

curl -v http://127.0.0.1:8093/query/service -d 'prepared="6562c30f-293e-449e-813d-2d2939f4da14"&$name="%test%"'

all return the following error:

    "errors": [
        {
            "code": 4050,
            "msg": "Unrecognizable prepared statement - cause: Invalid prepared stmt \"\u003cbinary (36 b)\u003e\""
        }
    ],
#10

The following Query works:

curl -v http://127.0.0.1:8093/query/service -H "Content-Type: application/json" -d  \
'{ "prepared":"getNameTest", "encoded_plan":"H4sIAAAJbogA/5xSwY7aMBT8FcvtgUi0UqWe0hMHkHpoi6C3qiJW/EgeOHbWdtgAyn77vpdlyQJ7WW72eDxvZuyjBJs7DXpVG2VlKuVYWlUBrQqIv2n1F0Ik0NXgVXRepkf5adjIJTw0JAFEecpLNNoDyfy7JE2aWDqPB2b1pLtU5h4r5ffLnIyOJVoNLaE16vaLht33/WFD8Bb2oVY5BxhATjSga9UYjtQEtAUHDSi78dUs5ZUxYM6G7nI8g5iXHzF1bWOGJoLn1pzVGNHxE41Go+wkk33NWCZLBAZhXRQVBk6VCGW1eI9ncAviM2+S5GbcT0szlJl7t4GcK/IQyNaKPFShTwdtzcRbYdn9vzVvBy06ZoasPe7QQAGBGz3lTl9bSb911yrL6EFVvbwMWFgVGw989/RNN4FKobMIbeSHW0znk8VUvPm9Yrb480sEMORD8C2x9q4S5wjisQQPLyeXNfYt9vhQ2w/ZPQcAAP//1n7muzUDAAA=", "$name":"%test%" }' 
1 Like