Up Prev Next
From: "Avis, Ed" <avised at kbcfp dot com>
Subject: RE: No error raised for bad SQL in prepare() or fetchall_arrayref()
Date: May 6 2004 4:34PM
>> my $sth = $dbh->prepare('malformed junk');
>Err - no $sth->execute().
However, I still think the error handling could be improved:
- Should give error when you try to fetch from a statement handle that
has not been execute()d.
- Arguably, prepare() should be the call that goes to the database and
compiles the query. Then it can check the query is syntactically
valid and matches the schema.
At the moment it looks like preparing the query doesn't happen on
prepare() but is deferred until the first call of execute(), is that
correct? I expect this is to reduce round trips to the DB.
If the first bit of error checking (not letting you fetch from an
unexecuted statement) were implemented then there would be less need
for immediate error checking on prepare().