use DBI; # Load the DBI module use CGI; # HTML use strict; # keep it usable use CGI qw(:standard); use CGI::Carp qw( fatalsToBrowser ); ### my ($sth); my ($ccode,@ccode); my(@data,$data); my ($p_str,@p_str); my $i=0; # counter my ($CC,@CC); my ($po,@po); my ($old,$new); my (@old,@new); my $count; my $total; my ($head_date,@head_date); my $rts; open (CC,"ccchg.txt"); while ($_=) { push (@CC,$_); ($old,$new)=split(/\|/,$_); push @old,$old; push @new,$new; } close (CC); $i=0; while ($i<@new) { print "old $old[$i] new $new[$i] "; $i++; } #print "$i - EYE \n"; ### Attributes to pass to DBI->connect() to disable automatic ### error checking my %attr = ( PrintError => 0, RaiseError => 0, ); ### Perform the connection using the Informix driver my $dbh = DBI->connect( "dbi:Informix:nps\@sumitt_aaa","xxx","yyyy" ,\%attr )or die "Can't connect to database: ", $DBI::errstr, "\n"; $sth=$dbh->prepare("SELECT a.rts_nbr, a.ccode, b.orig_date FROM rtsdet a, rtshead b WHERE a.rts_nbr=b.rts_nbr AND b.status MATCHES '[456OP]' AND b.orig_date>'2002/01/01' "); # AND b.time_stamp>'2002-01-01 00:00:00' - using TIME STAMP $sth->execute(); #print "old cc: $old \n"; # will dump out all fields $data=$sth->dump_results(); #$data=$sth->dump_results(); while ( ($po, $ccode,$head_date) = $sth->fetchrow_array() ){ push @po,$po; } print "$po \n"; $sth->finish; $sth=$dbh->prepare("SELECT rts_nbr,ccode FROM rtsdet WHERE ccode=? AND rts_nbr=?"); foreach $po(@po) { for ($count=0;$count<@old;$count++) { $sth->execute($old[$count],$po); while ( ($rts,$data) = $sth->fetchrow_array() ){ print "$po $rts $data $old[$count] $new[$count] \n"; } } } $sth->finish; $p_str=@po; print " POs: $p_str \n"; #### help?