在GridDB中执行SQL查询时遇到错误

问题描述 投票:0回答:1

我正在使用 GridDB 并尝试执行 SQL 查询,但出现错误。我创建了一个容器并向其中添加了一些数据。当我尝试执行查询时,收到一条错误消息,指出“‘查询’附近存在语法错误”。我已尝试多次使用不同的查询,但得到相同的错误。

// Connect to GridDB cluster
GridStore *store = GridStoreFactory::get_instance()->get_gridstore("your_ip_address", 31810, "your_cluster_name", "your_username", "your_password");

// Get a collection
Collection<Row> *collection = store->get_collection<Row>("Data");

// Create a query object
Query<Row> queryObj = collection->query("SELECT * FROM your_container_name WHERE your_column_name = 'your_value'");

// Execute the query
RowSet<Row> *rs = queryObj.fetch();

// Iterate over the result set
while (rs->has_next()) {
    Row *row = rs->next();
    // Do something with the data
}

// Release the resources
delete rs;
delete collection;
store->close();

Griddb::Exception:代码:4,原因:GS_ERROR_QUERY_INVALID_SYNTAX,指定查询的语法无效。 (未知错误代码):query="SELECT * FROM WHERE = 'value'"

griddb
1个回答
0
投票

您查询的类型是什么?我问这个是因为如果你查询的是 num/int/bool 类型,单引号会导致查询失败。所以如果不是字符串类型,请删除单引号。

如果是时间戳类型,当然你需要做更多的转换或者在这里分享更多的信息

© www.soinside.com 2019 - 2024. All rights reserved.