#!/usr/bin/perl -w

use DBI;
require "password.pl";

# Connect to the nations database
my $dbh = DBI->connect("DBI:mysql:nations", "randy", $password) || die "Can't co

# Create new table
$dbh->do("create table newBordersByKurt (Code1 char(2),Code2 char(2), Length flo

######################################
#                                    #
# READING IN ORIGINAL BORDERS TABLE  #
#                                    #
######################################

# First, prepeare the statement

my $sth = $dbh->prepare("select * from borders");

# Execute it

$sth->execute() || die "Error executing SELECT statement!";

# Fetch data & spit it into new table
#
# NOTE BY RANDY:  This is a WWEIRD way to use $sth.  Better
#is to have a NEW $sth inside the loop
while (@row = $sth->fetchrow_array())
	{
	# Uncomment the following line for debugging purposes
	# print "$row[0],$row[1],$row[2]\n";
	my $sth = $dbh->prepare("insert into newBordersByKurt values('$row[0]','$row[1]
	$sth->execute() || die "Error spitting in new info!";
	}

# Debug Print
print "Done... dropping table and disconnecting....";

# Drop new table
# $dbh->do("drop table newBordersByKurt");
	
# Disconnect
$dbh->disconnect();

# Time for positive reinforcement
print "\n\n\t\t\t\tALL GOOD\n\n\n";
