I've been working on support for execute_for_fetch in DBD::ODBC. I've
been looking around for testers and as usual the DBIx::Class users have
come up trumps. However, a question has arisen on irc #dbi which
although I believe I know the answer to it is not specifically mentioned
in the DBI docs.
If I use bind_param(N, $param, {TYPE => sql_type}) the parameter is
bound as a sql_type.
If I use execute_for_fetch I don't believe there is a way to specify the
parameter type.
However, DBI talks about sticky types (mostly wrt bind_col) and since I
added support for sticky types to DBD::ODBC (a few years ago) the
following actually works:
my $s = $h->prepare(q/some sql/);
$s->bind_param(1, undef, {TYPE=>SQL_DECIMAL});
$s->execute_for_fetch($fetch_tuple_sub);
as DBD::ODBC knows you bound p1 as SQL_DECIMAL so when you call
execute_for_fetch and it describes the parameters it knows p1 has had
its type overridden as a SQL_DECIMAL (despite what SQLDescribeParam says
in ODBC). It does not care you called bind_param and set p1 to undef as
that is ignored when execute_for_fetch is called.
It appears DBIx::Class uses parameter types a lot and is looking at
improvements using execute_for_fetch. I suggested to the DBIx::Class
guys the sticky parameter type was probably valid (and certainly is in
DBD::ODBC) but is this the intention of DBI?
Martin