Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am using Sybase::DBLIB to send 4000 to 40,000 update commands to a Sybase database. do you recommend I batch the commands and send them all at once or send them individually? I tried to batch them in 500 commands. Then when I attempted to send the 2nd batch I got the error: "Attempt to send a command with results still pending" Is there a way to determine if Sybase is still processing the last commands I sent?

Replies are listed 'Best First'.
Re: updating data in Sybase
by mpeppler (Vicar) on Jun 01, 2007 at 05:55 UTC
    The error simply means that you aren't processing the results from your request(s) correctly.

    The basic loop should look like this:

    $dbproc->dbcmd($the_sql_cmd); # possibly add more commands to the SQL buffer with additional # dbcmd() calls # Send the command(s) to the server $dbproc->dbsqlexec; # Process all the results while($dbproc->dbresults != NO_MORE_RESULTS) { # Process any rows that might be returned: while(@data = $dbproc->dbnextrow) { ..... # do something with the data } }
    What you need to realize is that for each INSERT, UPDATE, etc. in your SQL buffer you must call dbresults() at least once - hence the loop until dbresults() returns NO_MORE_RESULTS.

    Michael

Re: updating data in Sybase
by Anonymous Monk on Jun 01, 2007 at 14:35 UTC
    Thanks Michael It works great!