# --------------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------------- # Update the selected Database record sub UpdateDb { $Dbh = DBI->connect($DbConnectionInfo,$DbUserid,$DbPasswd); $Sth = $Dbh->prepare($UpdQuery); $Sth->execute() or $ErrNum = "3007"; $ErrMess = "$DBI::errstr"; $Sth->finish(); $Dbh->disconnect; print "HIER $ErrMess
" } # --------------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------------- # Query the database, and replace the labels with global values if ($ErrNum eq "0") { $RangeQuery = "WHERE $Field LIKE '%$String%' ORDER BY LstNum ASC"; $Dbh = DBI->connect($DbConnectionInfo,$DbUserid,$DbPasswd); $Sth = $Dbh->prepare("SELECT LstNum, LstName31, LstName01, LstSize, LstDesc31, LstDesc01, LstPurch, LstSaleP, LstSaleW, LstAmount, LstInfo FROM $DbTable $RangeQuery"); $Sth->execute or print "$DBI::errstr"; while (($LstNum, $LstName31, $LstName01, $LstSize, $LstDesc31, $LstDesc01, $LstPurch, $LstSaleP, $LstSaleW, $LstAmount, $LstInfo) = $Sth->fetchrow_array){ if ($Field eq "LstName31") { if ($Replace ne "") { print "String: $String
"; print "Replace: $Replace

"; $LstName31Old = $LstName31; $LstName31 =~ s/$String/$Replace/i; print "Updated $LstNum:
Old Value: $LstName31Old
New Value: $LstName31
"; } if ($NewValue ne "") { print "String: $String
"; print "NewValue: $NewValue

"; $LstName31Old = $LstName31; $LstName31 = $NewValue; print "Updated $LstNum:
Old Value: $LstName31Old
New Value: $LstName31
"; } if (($Replace eq "") and ($NewValue eq "")) { print "Current $LstNum:
Current Value: LstName31 $LstName31
"; } $UpdQuery = "UPDATE $DbTable SET LstName31 = '$LstName31' WHERE LstNum = '$LstNum'"; UpdateDb(); } } $Sth->finish(); $Dbh->disconnect; } if (($Replace eq "") and ($NewValue eq "")) { print "

$Mess
"; print "No new values received. No records are updated"; } # --------------------------------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------