Multiples inserts using DB-Lib/MSSQL 7.

Vanderlei Silva vandersilva at hotmail.com
Wed Dec 1 19:40:13 EST 1999


  Hello,
  I'm trying to write a migration app in order to transfer our data from
mySql to MSSQL 7. Using DB-Lib via freeTDS.
  The following code generates, apparently, good logs in /tmp/freetds.log
but the true is that only 1 or two rows are really affected in the server.

  dbinit();
  login = dblogin();
  DBSETLPWD(login,"xxx");
  DBSETLUSER(login,"xxx");
  DBSETLAPP(login,"sqsh");
  DBSETLHOST(login,"x.x.x.x");
  dbproc = dbopen(login, "IMSSQL");
  dbuse(dbproc, "REGISTRATION");
  .
  .
  . 
  while((qrow = mysql_fetch_row(qresult))) {
    if (qrow[0]  != NULL) data.memory = atol(qrow[0]);
    if (qrow[1]  != NULL) strcpy(data.platform,    qrow[1]);
    sprintf(final_sql_cmd, sql_cmd, data.memory, data.platform);
    dbcmd(dbproc, final_sql_cmd);
    dbsqlexec(dbproc);
  }
  .
  .
  .
  
  I noticed that if I stop the loop after the first 2 insertions, these 2 
rows are successfully stored in the server. So, I put the a counter and the 
following code after the dbsqlexec:
    if ( (i % 2) == 0) {
      sleep(1);
    }
And, it started working fine. But, as you can see, for a big database this 
approach is unacceptable. Any clue???


  Thanks guys,
  Vanderlei Silva,


   

  



More information about the FreeTDS mailing list