my ($data_set_01, $data_set_02, $format, @data_cat) = @_; my ($dbh, $sth, $sql_01, $sql_02); my ($row1, $row2); my @ds1_rows = (); my @ds2_rows = (); # Process each table foreach (@data_cat) { #------------------ # Data Set 1 #------------------ # Create the query statment $sql_01 = "SELECT * FROM " . $_; # Insert the where clause to the query. # This narrows the data chosen to the data_set the user is currently looking at. insert_where_clause(\$sql_01, $where_clause_ds1); # Connect to the database. if (! open_database_connection ( \$dbh, $program_config{database}, $program_config{admin_login}, $program_config{admin_pass} ) ) { # Indicate that a problem occured. return 0; } # Execute the query if (! execute_query(\$dbh, \$sth, $sql_01)) { return 0; } # get all records in table for the data set while ($row1 = $sth->fetchrow_array) { push @ds1_rows, $row1; } # Close the database connection. if (! close_database_connection (\$dbh)) { # Indicate that a problem occured. return 0; } #------------------ # Data Set 2 #------------------ # Create the query statment $sql_02 = "SELECT * FROM " . $_; # Insert the where clause to the query. # This narrows the data chosen to the data_set the user is currently looking at. insert_where_clause(\$sql_02, $where_clause_ds2); # Connect to the database. if (! open_database_connection ( \$dbh, $program_config{database}, $program_config{admin_login}, $program_config{admin_pass} ) ) { # Indicate that a problem occured. return 0; } # Execute the query if (! execute_query(\$dbh, \$sth, $sql_02)) { return 0; } # get all records in table for the data set while ($row2 = $sth->fetchrow_array) { push @ds2_rows, $row2; } print $ds2_rows[0]."\n"; # Close the database connection. if (! close_database_connection (\$dbh)) { # Indicate that a problem occured. return 0; } #------------------------------------ # Compare rows & output differences #------------------------------------ # compare each row in the first set of data to every row # in the second set of data. If it does not occur, then # they are different, so print. foreach (@ds1_rows) { my $record1 = $_; foreach (@ds2_rows) { my $record2 = $_; # if the record cannot be found if ($record1 ne $record2) { print $record1."\n".$record2."\n\n"; } } } # empty arrays for next table @ds1_rows = (); @ds2_rows = (); }