[freetds] Warning: Null value is eliminated by an aggregate or other SET operation.

Jeff Dahl jddahl at micron.com
Fri Mar 24 19:29:21 EST 2006


Table:

    name varchar(20)   | value int
    ===================|==========
          a            |  null

Query:

    select sum(value) from Table


Why does the following code print out the last row twice.  Once with 
'ret == SQL_SUCCESS' and once when 'ret == SQL_SUCCESS_WITH_INFO'?

     while(( ret = SQLFetch( cmd )) != SQL_NO_DATA )
       {
         if( ret == SQL_SUCCESS_WITH_INFO )
           {
             // print warning
           }
         else if( ret == SQL_ERROR )
           {
             // print error
           }
         // print row
       }

If I wrap the print in an else, I only get one row:

    while(( ret = SQLFetch( cmd )) != SQL_NO_DATA )
      {
        if( ret == SQL_SUCCESS_WITH_INFO )
          {
            // print warning
          }
        else if( ret == SQL_ERROR )
          {
            // print error
          }
        *else*
          {
            // print row
          }
      }

It appears that when SQLFetch returns with SQL_SUCCESS_WITH_INFO, 
another row is appended with the same data and  a return status of 
SQL_SUCCESS.  Is this standard behavior?  Should two rows be returned 
with different SQLSTATEs?

Thanks,
Jeff Dahl



More information about the FreeTDS mailing list