zoukankan      html  css  js  c++  java
  • cassandra cpp driver中bind list——用cass_statement_bind_collection函数

    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;
    }

    备忘!

  • 相关阅读:
    Linux Apache服务(一)
    mysql基础
    linux面试题一
    linux shell(2)
    linux基础汇总2
    python列表生成式、生成器,迭代器与二分法
    python的函数
    python函数
    java 翁老师学习笔记-持续更
    责任链模式
  • 原文地址:https://www.cnblogs.com/bonelee/p/6548921.html
Copyright © 2011-2022 走看看