# -------------------------------------------------------------------- +------------------------------------------- # -------------------------------------------------------------------- +------------------------------------------- # -------------------------------------------------------------------- +------------------------------------------- # 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<br>" } # -------------------------------------------------------------------- +------------------------------------------- # -------------------------------------------------------------------- +------------------------------------------- # -------------------------------------------------------------------- +------------------------------------------- # 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, LstI +nfo FROM $DbTable $RangeQuery"); $Sth->execute or print "$DBI::errstr"; while (($LstNum, $LstName31, $LstName01, $LstSize, $LstDesc31, $Ls +tDesc01, $LstPurch, $LstSaleP, $LstSaleW, $LstAmount, $LstInfo) = $St +h->fetchrow_array){ if ($Field eq "LstName31") { if ($Replace ne "") { print "String: $String<br>"; print "Replace: $Replace<br><br>"; $LstName31Old = $LstName31; $LstName31 =~ s/$String/$Replace/i; print "Updated $LstNum:<br>Old Value: $LstName31Old<br +>New Value: $LstName31<br>"; } if ($NewValue ne "") { print "String: $String<br>"; print "NewValue: $NewValue<br><br>"; $LstName31Old = $LstName31; $LstName31 = $NewValue; print "Updated $LstNum:<br>Old Value: $LstName31Old<br +>New Value: $LstName31<br>"; } if (($Replace eq "") and ($NewValue eq "")) { print "Current $LstNum:<br>Current Value: LstName31 $L +stName31<br>"; } $UpdQuery = "UPDATE $DbTable SET LstName31 + = '$LstName31' WHERE LstNum = '$LstNum'"; UpdateDb(); } } $Sth->finish(); $Dbh->disconnect; } if (($Replace eq "") and ($NewValue eq "")) { print "<br><br>$Mess<br>"; print "No new values received. No records are updated"; } # -------------------------------------------------------------------- +------------------------------------------- # -------------------------------------------------------------------- +------------------------------------------- # -------------------------------------------------------------------- +-------------------------------------------
In reply to DBD problem by Umdurman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |