[unixODBC-dev] Patch to retrieve error on SQL_NO_DATA

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Wed Nov 30 18:24:19 GMT 2005


> 
> ZIGLIO, Frediano, VF-IT wrote:
> > As specifications diagnostic data can be returned even on 
> SQL_NO_DATA
> > (for example if SQLExecDirect do not get any row). This fix 
> the problem.
> > Currently is the only way to make DBD::ODBC and FreeTDS happy :)
> > 
> > diff -r -u unixODBC-2.2.11.orig/DriverManager/__info.c
> > unixODBC-2.2.11/DriverManager/__info.c
> > --- unixODBC-2.2.11.orig/DriverManager/__info.c 2005-11-29
> > 12:08:54.000000000 +0100
> > +++ unixODBC-2.2.11/DriverManager/__info.c      2005-11-29
> > 12:10:44.000000000 +0100
> > @@ -4874,8 +4874,7 @@
> >      DMHSTMT hstmt;
> >      DMHDESC hdesc;
> > 
> > -    if ( ret_code == SQL_ERROR ||
> > -            ret_code == SQL_SUCCESS_WITH_INFO )
> > +    if ( ret_code != SQL_SUCCESS )
> >      {
> >          /*
> >           * find what type of handle it is
> > 
> > freddy77
> > 
> Ok,
> 
> Just one question, how does the app know its meant to check for any 
> diagnostics?
> 

It call SQLGetDiagRec (or similar) to check if there are some
informations. If SQLGetDiagRec return SQL_NO_DATA here it means that
there are no diagnostic. For SQLExecDirect SQL_NO_DATA is "stronger"
than SQL_SUCCESS_WITH_INFO so if there are diagnostics and no data
SQL_NO_DATA is returned. Some tests in DBD::ODBC require this behavior.

freddy77




More information about the unixODBC-dev mailing list