sub create_temp_tables($$) { # Create copies of sp047 and sp057 for updating my ($dbh, $dbms) = (@_); my $sql; if ($dbms eq 'ORACLE') { $sql = q{create table sp047_postcodes_temp as select * from sp047_postcodes}; $sql = q{create table sp057_regions_temp as select * from sp057_regions}; } else # SQLServer { $sql = q{select * into sp047_postcodes_temp from sp047_postcodes}; $sql = q{select * into sp057_regions_temp from sp057_regions}; } $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); } }