List:General Discussion« Previous MessageNext Message »
From:Jay J Date:September 26 1999 11:18am
Subject:Re: UPDATE
View as plain text  
----- Original Message -----
From: <toxalot@stripped>
To: <mysql@stripped>
Sent: Sunday, September 26, 1999 3:25 AM
Subject: UPDATE

> I'm using perl and DBI.
>
> I have an edit form that outputs the content of a particular record. On
> submit of this form, I'm updating the table, but I didn't make any changes
> to the data that I am sending in the update. Shouldn't I get a return code
> of 0 if there are no changes?
>
> I am getting a code of 1.  What am I doing wrong? Any ideas?
>
[snip]
> $rc=$dbh->do( $sql ) or die ("Do failed:  $DBI::errstr");
> $dbh->disconnect();
> if ($rc == 0) {print "There was nothing to update.<br>\n";}
> else {
> print "Changes were saved to the database.<br>\n";
> }

shell> perldoc DBI | grep ">do"  -A 4
--
             $rc  = $dbh->do($statement)           || die $dbh->errstr;
             $rc  = $dbh->do($statement, \%attr)   || die $dbh->errstr;
             $rv  = $dbh->do($statement, \%attr, @bind_values) || ...

           Prepare and execute a single statement. Returns the
           number of rows affected (-1 if not known or not
           available) or undef on error.

I realize this isn't the Perl style mailing list, but you might consider
alternate quoting mechanisms and perhaps a foreach() or map{} for the given
fields (as well as testing whether they're defined).

-Jay J



Thread
UPDATEtoxalot26 Sep
  • Re: UPDATEJay J26 Sep
  • UPDATEMichael Widenius26 Sep
    • Re: UPDATEtoxalot27 Sep