Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: RE: No error raised for bad SQL in prepare() or fetchall_arrayref()
Date: May 6 2004 4:49PM
On Thu, 2004-05-06 at 18:34, Avis, Ed wrote:
> >> my $sth = $dbh->prepare('malformed junk');
> >> $sth->fetchall_arrayref();
> >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.
Agreed - I'll look into that.
> - 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.
Actually the actual execution is deferred so that you can call execute()
multiple times on the same static SQL and get the behavior that DBI
expects. A prepare() with placeholders will flag the error earlier.
Michael Peppler Data Migrations, Inc.
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions - http://www.peppler.org/resume.html