Hi monks!
I'm very new to perl. In fact the only coding i have done is a basic VB using Mapbasic as I'm in GIS.
I'm trying to edit a script which someone left behind and I am really stuck here. I realised after a few stupid minutes that my edit in which I've added 2 SQL updates cant be done and it can only prepare 1 statement which i believe is the last one, so how can I loop the code below to run both sql updates?
Many many thanks!
Gareth
I have posted my sub routine below:
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 * fr
+om sp057_regions};
}
else # SQLServer
{
$sql = q{select * into sp047_postcodes_temp from sp047_
+postcodes};
$sql = q{select * into sp057_regions_temp from sp057_re
+gions};
}
$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);
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.