Multiples inserts using DB-Lib/MSSQL 7.

Vanderlei Silva vandersilva at hotmail.com
Thu Dec 2 19:18:55 EST 1999



> > >Vanderlei Silva writes:
> > >  >   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 guess it's a typo, but... you *do* have a loop on dbresults() in
> > >there too, right?
> > >
> > >Michael
> >
> >   No, no loop on dbresults(). The command in final_sql_cmd is a INSERT. 
>So,
> > I'm not analysing the results. Should I?
> >   Can the problem be related to the fact that maybe my SQL Server is not
> > able to process a lot of requests (one after the order very fast, like 
>100
> > per second!!!)???
> >   Any help will be valuable.
> >
> > Vanderlei Silva
> >
>You really should do a 'while (dbresults(dbproc)!=NO_MORE_RESULTS) {}'.
>As to why it works if you put a 1 second delay in....I'm baffled, my guess
>would be that if the server has not yet sent the response then another
>query is not allowed....by processing the result set, you know that the
>server has finished the insert.
>
>Brian

Yahh!!! A 100/100 right!
Before I was using a delay of 1 miliseconds between commands, plus closing 
and reopening the connection every 1000 commands. Crazy! :)
Now, by just adding the result set, the synchronization went fine!
Curious the MSSQL was accepting my requests before!!!

Thanks everybody!

Vanderlei Silva









______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com



More information about the FreeTDS mailing list