Create, execute and delete prepared statements in cbq

n1ql

#1

In Couchbase’s console interface cbq, how do I create, execute and delete prepared statements? In the documentation, there’s only instruction for the REST api.

Thanks.


#2

Found another place in the doc where it says cbq is not supported.


#3

Hi cbq does not allow prepared statement execution fully today. We will be previewing the next version of cbq tool that will provide better support for these facilities.
Here is a quick sample you can use to see prepared executions;

  • First call prepares a statement.

prepare sample_query from select * fromtravel-sampleuse keys "airline_10";

  • Second call loops through an execution of the named prepared statement using prepared=“sample_query”

Full script below:

curl -v 
http://localhost:8093/query/service?statement=prepare%20sample_query%20from%20select%20*%20from%20%60travel-sample%60%20use%20keys%20%22airline_10%22;
for i in `seq 1 100`; do
             curl -v http://localhost:8093/query/service?prepared=%22sample_query%22
done

#4

@cihangirb Thank you! I ended up using the java sdk to execute the prepared statement.


#5

Have already replied in another thread, but, for completeness, in Watson you will be able to do the whole prepare statement / execute prepare statement / delete prepared statement straight from cbq.