As an alternative, consider using one of the higher-level DBI wrappers on CPAN; I'm personally fond of my own
DBIx::SQLEngine, but there are a number of decent choices.
Here's a possible skeleton implementation:
# Create a SQLEngine wrapper around your existing connection
my $sqldb = DBIx::SQLEngine->new( $dbh );
# Get an array of hashes
my $extracted = $sqldb->fetch_select( sql => <<'/' );
SELECT extracted_ads_id, prop_street_no, prop_street_name
FROM extracted_ads_tbl
WHERE pin-on-off=0
/
# Build a hash of arrays mapping ad_ids to property info
my %extracted = map {
$_->{extracted_ads_id} => [ $_->{prop_street_no}, $_->{prop_street
+_name} ]
} @$extracted;
# ... now build your web requests and hash of PINs
my %pin_results = ...;
# Do inserts for each resulting record
foreach my $ads_id ( keys %pin_results ) {
$sqldb->do_insert( sql => [ <<'/', $ads_id, $pin_results{$ads_id} ]
+);
INSERT INTO enhanced_ads_tbl
(enhanced_ad_id,extracted_ads_id,pin)
VALUES (NULL,?,?)
/
}
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.