use strict; use warnings; sub create_temp_tables($$) { # Create copies of sp047 and sp057 for updating my ($dbh, $dbms) = (@_); my @sqls; if ($dbms eq 'ORACLE') { push @sqls, q{create table sp047_postcodes_temp as select * from sp047_postcodes}; push @sqls, q{create table sp057_regions_temp as select * from sp057_regions}; } else # SQLServer { push @sqls, q{select * into sp047_postcodes_temp from sp047_postcodes}; push @sqls, q{select * into sp057_regions_temp from sp057_regions}; } foreach my $sql (@sqls) { my $sth = $dbh->prepare($sql); if ($sth) { my $rc = $sth->execute(); if ($sth->err) { myexit($sth->errstr, $dbh); } else { # Need to commit to release locks in SQL Server - we have done nothing else at this stage, # so no problem with this. $dbh->commit; } $sth->finish; } else { myexit("Unable to prepare SQL : " . $sql . "\n", $dbh); } } }