RE: There's an error, but $sth->execute returns -1

[email protected] ("Roode, Eric")
Newsgroups perl.dbi.users
Message-ID <[email protected]>
On Saturday, October 16, 2010 6:18 AM, Martin J. Evans wrote:

> On 15/10/2010 22:20, Roode, Eric wrote: 
>> Hello all,
>> 
>> DBI docs says that statement handle method execute() returns undef on
>> error.  I have found a situation where that does not hold.  Was
hoping
>> someone could help me out, maybe there's a workaround.
>
> You need to read further down that entry where it says:
>
> "If the number of rows affected is not known, then execute returns
-1."
>
> Admittedly, in your case it looks like an error from the driver
> error message but it did not return an error so perhaps you stopped
> when you saw undef for error.

I knew perfectly well that -1 means "number of rows unknown".  I didn't
see how that could apply to "[Microsoft][ODBC SQL Server Driver][SQL
Server]Cannot insert the value NULL into column 'enabled', table
'feeds'; column does not allow nulls. INSERT fails. (SQL-23000)
[state was 23000 now 01000] [Microsoft][ODBC SQL Server Driver]
[SQL Server]The statement has been terminated. (SQL-01000)"

That's just an error, plain and simple.  I'm perfectly willing to
accept that it may not have been reported as an error, due to a bug in
Microsoft's driver or whatever, but to suggest that I didn't read the
docs and therefore didn't interpret -1 correctly is ridiculous.

-- Eric
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.