Re: Is it ever legal (should be supported) to issue a non select in selectall_arrayref?

David Nicol <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On Wed, Jun 29, 2011 at 3:02 AM, Martin J. Evans
<[email protected]> wrote:

>> BEGIN THING TO INSERT
>> =head3 On use of non-C<SELECT>  SQL in C<select*_*>  methods
>>
>>  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
>> a C<fetch*>  called within an C<eval>  block will work.
>> END THING TO INSERT
>
> Unfortunately this does not hold true for DBD::ODBC:

How to emphasize "called within an C<eval> block" ???


> perl -le 'use DBI; my $h = DBI->connect(); my $s = $h->prepare("create table
> fred (a int)"); $s->execute; my $r = $s->fetch;'
> DBD::ODBC::st fetch failed: no select statement currently executing
> (SQL-HY000) at -e line 1.

Right, right! What happens when you put an C<eval> around the fetch?

perl -le 'use DBI; my $h = DBI->connect(); my $s = $h->prepare("create
table fred (a int)"); $s->execute; my $r = eval {$s->fetch};'

That is, are there any drivers where calling a bogus fetch WITHIN AN
EVAL BLOCK has any side effects? Error counters that max out, or
anything like that?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.