CassError insert_into_collections(CassSession* session, const char* key, const char* items[]) { CassError rc = CASS_OK; CassStatement* statement = NULL; CassFuture* future = NULL; CassCollection* collection = NULL; const char** item = NULL; const char* query = "INSERT INTO examples.collections (key, items) VALUES (?, ?);"; statement = cass_statement_new(query, 2); cass_statement_bind_string(statement, 0, key); collection = cass_collection_new(CASS_COLLECTION_TYPE_SET, 2); for (item = items; *item; item++) { cass_collection_append_string(collection, *item); } cass_statement_bind_collection(statement, 1, collection); cass_collection_free(collection); future = cass_session_execute(session, statement); cass_future_wait(future); rc = cass_future_error_code(future); if (rc != CASS_OK) { print_error(future); } cass_future_free(future); cass_statement_free(statement); return rc; }
备忘!
本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6548921.html,如需转载请自行联系原作者