On Sat, Oct 16, 2010 at 11:03:08AM +0100, 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.
>
> (Tim Bunce, if you see this could you clarify what dbd_st_execute is
> supposed to return as I could not find the full details in DBI::DBD.
> It would appear DBD::ODBC returns -2 for error, -1 for rowcount not
> known and a positive number for rows affected).

I see it's not mentioned in the DBI::DBD docs.  From Driver.xst:

    retval = dbd_st_execute(sth, imp_sth);
    /* remember that dbd_st_execute must return <= -2 for error */
    if (retval == 0)            /* ok with no rows affected     */
        XST_mPV(0, "0E0");      /* (true but zero)              */
    else if (retval < -1)       /* -1 == unknown number of rows */
        XST_mUNDEF(0);          /* <= -2 means error            */
    else
        XST_mIV(0, retval);     /* typically 1, rowcount or -1  */

> The status returned was SQL_SUCCESS_WITH_INFO:
> 
> !!dbd_error2(err_rc=1, what=st_execute/SQLExecute,
> handles=(3194c98,2b5a848,30d4cd0)
> 
> that err_rc=1 which is not an error.
>
> If SQLRowCount returns -1 then dbd_st_execute will return -1, that
> may be a bug but really the code should not have got to this point
> anyway. The are differences between what DBI documents for the
> execute method and what DBD::ODBC returns from the dbd_st_execute
> and I cannot see for instance the -2 (for errors) documented in
> DBI::DBD so I'm not sure if this is right or wrong (Tim?).

It should be documented that dbd_st_execute should return <= -2 to
indicate an error.

Tim.

> As far as I can see this looks like a bug in your driver (but I'll
> try and reproduce here). Surely failing to insert into a column
> should be an error not success with info (an example of the latter
> is say an insert which worked but truncated your data). What ODBC
> Driver manager and driver versions are you using - you can find
> these from the Administrative tools, data sources or in windows 7 by
> searching for data sources in the control panel top right.
> 
> Martin
> 
> 

Reply via email to