A L [EMAIL PROTECTED] wrote:
> Dear [EMAIL PROTECTED],
>  
> Okay, so, by being ignored, it dawned on me that my question may have been 
> considered to be stupid.  But, since my goal is to program better, more time was 
> spent, even though spending a whole week checking the code and looking at whatever 
> books could be found to figure out what was wrong with it (thinking it should have a 
> simple solution) didn't produce any result .  
>  
> Although my code does function when WHERE in the prepare statement is specified 
> within a database, it isn't exactly what was intended.  This code should 
> automatically update all the rows when there are matching idnum with same file name 
> without having to type specific name for WHERE (for example, not WHERE='Sally" but 
> WHERE=?).  With another program example, which uses the same prepare and excute 
> statement format as this code, the code works, but not in this program.  Both 
> program looks the same to me, but this one isn't working.  And, I can't figure out 
> why.  
>  
> It really would help me a lot if you would spend a little bit of time to show me why 
> it's not working, even if you find this question to be stupid.  To me it is not, it 
> is important to me to understand why I don't get this.  Any feedback would be much 
> appreciated.
> Angela
>  
> #!/usr/bin/perl
> use DBI;
> my $dbh = DBI->connect("dbi:mysql:", "usrname", "password") || die $DBI::errstr;
> my $db_database = DBI->connect("dbi:mysql:database", "usrname", "password") || die 
> $DBI::errstr;
> my $insert_database=$db_database->prepare("INSERT INTO table1 values 
> (?,?,?,?,?,?,?)");
> my $dbh1 = DBI->connect("dbi:mysql:database", "usrname", "password") || die 
> $DBI::errstr;
> my $lookup_access=$dbh1->prepare("select  retrieval_date FROM table1 WHERE idnum= 
> ?");
>   
> $Top="/home/Top/";
> chdir $Top;
> my $count=0;
> while (my $subdir=<*>){
>   chdir $subdir;
>     while (my $file=<*.txt>){
>  $file=~/^(\w*)./;
>  my $access=$1;
>  $lookup_access->execute($access);
>  my @result=$lookup_access->fetchrow();
>  my @file=stat("$access.txt");
>  my $mtime=$file[9];
>  my @testime=gmtime($mtime) ;
>  my $year=$testime[5]+1900;
>  my $mon=$testime[4]+1;
>  my $mday=$testime[3];
>  my $mon=sprintf("%02d",$mon);
>  my $mday=sprintf("%02d",$mday);
>  my $date= "$year-$mon-$mday";
>  if (@result){
>   my $result=$date;
>   if ($result){
>    my $update_table1=$dbh1->prepare( 
>     "UPDATE table1 
>     SET retrieval_date='$result' 
>     WHERE idnum='Sally");#need to work for all the updated files, not just one file
>    $update_table1->execute();
>    }
>   }
>  }
>  chdir "..";
>  
> }
> $dbh->disconnect;

You need to provide some prior context or information -
Start with pasting in some of the input, some of the output,
what (if any) error messages do you get, what is happening,
what *should* happen.  Tell us enough about your problem
so that we can help you.
-- 
Hardy Merrill
Red Hat, Inc.

Reply via email to