in reply to Re^2: Superior way to update SQL tables
in thread Superior way to update SQL tables

I used do() for illustrative purposes. I would actually recommend using prepare_cached()/execute() instead of prepare()/execute(). do() has to re-prepare the statement, which can take time.

As for your addto_Skip(@row) thing, that's up to you. If you expect to have rows that you cannot insert or update, that would be a useful thing to have.

You can also do something like:

while (my @row = $sth->fetchrow_array ) { eval { $sth_insert->execute( @row ) }; next unless $@; eval { $sth_update->execute( @row ) }; next unless $@; addto_Skip( @row ); }

Though, personally, I would look at using fetch() with bind_columns(), as the best performance option that DBI supports. This is instead of the fetchrow_array().

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested