Hello here,

I am trying to use SOCI and especially do bulk insert using prepared 
statements, but no matter what I do it only inserts first value (row) during 
prepared statement execute() command.
Would really appreciate your help.

Here is code snippet:

backend_factory const &backEnd = *soci::factory_mysql();

    try {
     soci::session con;
     con.open(backEnd, connectString);


    std::vector<std::string> jobIds;
    std::vector<std::string> jobNames;
    std::vector<std::string> parentJobIds;
    std::vector<indicator> parentJobIdsIndicators;
    std::vector<std::string> users;
    std::vector<long long> submitTimes;
    std::vector<std::string> clusterIds;
    for (int i = 0; i < 10; i++) {
       char iA[10];
       sprintf(iA,"%d",i);
       std::string jobId("12345");
       jobId.append(iA);
      jobIds.push_back(jobId);
      jobNames.push_back(std::string("foo").append(iA));
      parentJobIds.push_back(std::string(""));
      parentJobIdsIndicators.push_back(i_null);
      users.push_back(std::string("testUser"));
      submitTimes.push_back(1234567);
      clusterIds.push_back(std::string("637022306616635968"));
    }
    soci::statement jobInsertPrepStmt = (con.prepare << "insert into JOB 
(JOB_ID, JOB_NAME, PARENT_JOB_ID, USER_SUBMITTED, TIME_SUBMITTED, CLUSTER_ID) 
values(:JOB_ID, :JOB_NAME, :PARENT_JOB_ID, :USER_SUBMITTED, :TIME_SUBMITTED, 
:CLUSTER_ID )", soci::use(jobIds), soci::use(jobNames), soci::use(parentJobIds, 
parentJobIdsIndicators), soci::use(users), soci::use(submitTimes), 
soci::use(clusterIds));

         jobInsertPrepStmt.execute(true);

    } catch (mysql_soci_error const &e) {
     // some error handling
   }
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to