in reply to Perl Beginners problem with DBI
If you changed the code to say:
it would work.$dbh->do("UPDATE INV SET SOLD=\"$updy\" WHERE CODE==$CODE");
But don't do that.
Instead, learn to use placeholders. It is true that they make you type more, but they take care of quoting problems like the one above:
If you are performing this stuff in a loop, you can move the prepare stage out of the loop, and speed it up.$sth=$dbh->prepare("UPDATE INV SET SOLD=? WHERE CODE==?"); $sth->execute($updy,$CODE); # Why is that var all UPcase, BTW?
Finaly, I don't know if your SQL database doesn't allow multiple updates in a single statement (most do), but if you're having that much trouble with writing SQL, you really should take a look at an abstraction layer like Class::DBI, which lets you treat database tables and rows as objects, and manipulate them more easily.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Perl Beginners problem with DBI
by Anonymous Monk on Mar 17, 2004 at 14:57 UTC | |
|
Re: Re: Perl Beginners problem with DBI
by iburrell (Chaplain) on Mar 17, 2004 at 19:19 UTC | |
by matija (Priest) on Mar 17, 2004 at 23:01 UTC |