在new一个MultithreadedTableWriter类的时候,最后一个参数的含义是:modeOption 字符串数组,表示不同模式下的扩展选项,目前,仅当 mode 指定为 M_Upsert 时有效,表示由 upsert! 可选参数组成的字符串数组。
upser!函数的用法为upsert!(obj, newData, [ignoreNull=false], [keyColNames], [sortColumns])
这里报错是因为在传入参数的时候colNames.push_back("int_value");只传入了一个参数,改为vector<string> colNames{"false", "`int_value"};就可以正常插入数据了。
int main() { static DBConnection conn(false, false); conn.connect("192.168.0.126", 8848, "admin", "123456"); vector<string> colNames{"false", "`int_value"}; SmartPointer<MultithreadedTableWriter> writer; writer = new MultithreadedTableWriter("192.168.0.126", 8848, "admin", "123456", "dfs://xhTradeDailyDb", "Test", false, false, NULL, 1, 1, 1, "", nullptr,dolphindb::MultithreadedTableWriter::M_Upsert,&colNames); ErrorCodeInfo errorInfo; writer->insert(errorInfo, rand() % 10000, "AAAAAAAB", rand() % 10000 + 0.1); if(errorInfo.hasError()){ cout << errorInfo.errorInfo <<endl; } return 0; }