On Mon Jun 13 11:31:25 2011, pedrinho@gmail.com wrote:
Show quoted text> Based on the responses do dbi-dev, I've got a further question:
>
> I'm not 100% sure about the assertion about calling fetch on an
> executed non-select statement handle being defined to reliably return
> false, as in no-more-data as part of the standard. If C<fetch*> isn't
> really defined to behave the same with a non-SELECT as with a SELECT
> that simply doesn't return any rows, like I think it is but not with
> certainty, the following is my submission as a patch to DBI.pm.
>
> --- a/DBI.pm Sat Jun 11 16:19:30 2011 -0500
> +++ b/DBI.pm Sat Jun 11 16:38:01 2011 -0500
> @@ -4621,6 +4621,16 @@
> You can specify a maximum number of rows to fetch by including a
> 'C<MaxRows>' attribute in \%attr.
> +=head3 On use of non-C<SELECT> SQL in C<select*_*> methods
> +
> +While some drivers support statements other than C<SELECT> in the
> above-listed
> +convenience functions, others do not. Requirement of this facility is
> not defined
> +by the DBI interface standard. The C<do> method is provided for
> non-C<SELECT>
> +statements. When you really don't know if the statement you have in a
> variable
> +is going to be a C<SELECT> or not, unrolling the process into
> C<prepare>,C<execute>,
> +and some C<fetch> variant will always work, as C<fetch> is defined to
> return
> +no data when called on executed non-C<SELECT> statement handles.
> +
Show quoted text> While it says that fetch() is defined to return no data, it doesn't appear
> to define whether an error/warning will be issued in this case. I thought
> I'd tested calling fetch() 2x and got the same message (which isn't to say
> that the statement failed, I didn't even check for that). How do you
expect
Show quoted text> prepare();execute();fetch() to work in 1.30_07 vs. fetchall_arrayref()?
>
> Thanks,
>
> -Peter
If you run the code you were running through selectall_* or fetchall_*
in DBD::ODBC via the latest version from subversion trunk you'll get an
error saying no select statement is running. It is my belief that this
is what you should get (and you would have got in older DBD::ODBCs until
I broke this aspect of error reporting) and that is what other DBDs do.
It is also the belief of the commentators on the issue I raised. I
cannot move this on - only DBI developers can.
I had intended releasing 1.30_7 this weekend but I was away. I'll try to
sort it out this week.
I cannot unilaterally change DBI and this issue is going beyond
DBD::ODBC. I've mentioned it before but you'd get a much wider audience
on dbi-users mailing list (see dbi.perl.org) and much more likely to get
a definitive answer or resolution.
Martin
--
Martin J. Evans
Wetherby, UK