select a.function_section.* from supplier_function where a.type = “FUNCTION” this is working correctly
String function = "FUNCTION"
select a.function_section.* from supplier_function where a.type = $function this is not returning any results
function variable will get populated with some values dynamically
which I want to pass into my N1QL in JAVA.
Thanks in Advance for you help
you can use PREPARED statement and query data via REST API,like
# Create PREPARE statement
curl -v http://127.0.0.1:8093/query/service --data-urlencode 'statement=PREPARE queryAllByType FROM select a.function_section.* from supplier_function a where a.type =$funtion; '
# query by PREPARE from client(JAVA)
curl -v http://127.0.0.1:8093/query/service -d 'prepared="queryAllByType"&$funtion="FUNCTION"'
Also, using Java SDK:
Example for named parameter:
This file has been truncated.
* Copyright (c) 2016 Couchbase, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
Thank you Keshav it really helps me