Named Parameters in the Web Console

curl should work. post exact command used

curl http://[node_ip]:8093/query/service -u Administrator:[password] -H "Content-Type: application/json" -d @students.sql > students_zero_points.txt

Where students.sql is

{
"statement":"SELECT t.studentId, t.houseId, ARRAY_LENGTH(t.points) AS points FROM hogwarts t WHERE t.type=\"record-txn\" and t.houseId = \"gryffindor\" and t.studentId IN $students and ARRAY_LENGTH(t.points) = 0;",
"$students": ["b393c367-ed05-445e-9795-fde7099d07e4"]
}

This query u have ARRAY_LENGTH(t.points) = 0 , use the following index.

CREATE INDEX ix2 ON hogwarts`(`houseId`, array_length(`points`) ,`studentId) 
WHERE (`type` = 'record-txn')

Screenshot 2022-01-09 at 8.22.31 PM

Still no luck :frowning:

Itā€™s working, sorry was using some other IP than that of a Couchbase node.

Canā€™t thank you enough for this help!! Iā€™ll learn more about Couchbase/N1QL and start contributing back to these forums myself!

Using the UI like this on version 7.1.5, I am only able to add values that are numbers, ā€œstringsā€, {braces} and [brackets]. Is there a way to represent NULL values using the work bench?

For example, to be used in a query like, ...AND $propCode IS NULL OR document.propCode = $propCode

Best optimal way, if possible use 2 statements (one null , non-null) because when named/positional parameters planner has to generate plan generically assume all possible cases.
i.e. $propCode is NULL it needs all rows from indexer with out field value
$propCode is not null only subset even one push to indexer due to OR other one produces all rows from indexer.

1 Like

in json, the unquoted string null is null.

Positional Parameters
$1 =
null

select $1 where $1 is null
[
{
ā€œ$1ā€: null
}
]

1 Like

Thank you. Total face palm moment. I was using capital letters like the query reserved word and the UI wouldnā€™t accept it.

might be oversight. MB-60464

All of the reserved words are case insensitive so I didnā€™t think to try.

Indeed the values for parameters need to be JSON, not N1QL/SQL++. And JSON doesnā€™t like NULL.

1 Like