aisa/scripts/db/admin/amend_db_towns_airportcode.pl

68 lines
1.4 KiB
Perl
Raw Permalink Normal View History

2025-11-26 09:31:54 +00:00
#!/usr/bin/perl
print "Content-type: text/html\n\n";
BEGIN { use lib '/usr/home/cfg' ; require push_inc ; }
require cfg ;
&today ;
#------------------------------------------------------------------------------------------
use DBI;
use CGI::Carp qw(fatalsToBrowser);
&load_towns ;
exit ;
#------------------------------------------------------------------------------------------
sub load_towns {
&db_open_ro ;
my $sql = qq(SELECT * FROM towns WHERE airportcode = '') ;
my $sth = $dbh->prepare($sql) ;
$sth -> execute() or die "Could not execute SQL statement $sql ... maybe invalid? $!";
my $array_ref = $sth->fetchall_arrayref();
$sth->finish();
&db_close_conn ;
# &db_open_upd ;
foreach $row (@$array_ref) {
&db_town_fields ;
&common_debug("$tn_town - $tn_opshubcode - $tn_airportcode") ;
# &update_towns($tn_townid,$tn_opshubcode) ;
}
# &db_close_conn ;
} #------------------------------------------------------------------------------------------
sub update_towns {
my ($townid,$airportcode) = @_ ;
unless ($airportcode) { return ; }
$sql = qq(UPDATE towns SET airportcode = '$airportcode' WHERE townid = '$townid' AND airportcode = ''
) ;
&common_debug($sql) ;
# $sth = $dbh -> do ($sql) or die "could not execute :<BR>$sql<BR>$!" ;
} #------------------------------------------------------------------------------------------
use db ;
use today ;
use common ;
1;