Skip to Content.
Sympa Menu

freetds - Re: [freetds] Using GROUP BY and COUNT

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] Using GROUP BY and COUNT
  • Date: Wed, 19 Dec 2012 15:51:07 -0500

On Wed, 19 Dec 2012 13:38:06 -0500
Jeremy Livingston <jeremyjlivingston AT gmail.com> wrote:

> Pardon my ignorance, but I'm not sure how to specify that driver that
> I'd like to use using bsqlodbc.

Look again at my example. :-) It's not a driver I'm using. bsqlodbc
is a FreeTDS command-line utility; it's found in src/apps and should
have been installed somewhere like /usr/local/bin when you installed
FreeTDS.

The point is to determine if the problem you're seeing is in the
FreeTDS ODBC driver (which the utility uses), or in the PHP module, or
in your application. I think you'll find bsqlodbc runs your query just
fine, which suggests the problem in not in the driver.

> For example: "SELECT COUNT(MiddleName) FROM Person"
> where MiddleName contains all null values will throw the error.

You might try these, too:

$ echo 'select count(t) from (select cast(NULL as int) as t) as T' \
| bsqlodbc -U$U -P$P -S$S
----------
0
bsqlodbc: error 8153: 01003: [FreeTDS][SQL Server]Warning: Null value
is eliminated by an aggregate or other SET operation.

If I stack a guess on a few assumptions, the most likely problem is
that the error message isn't handled correctly. For example, if PHP
stops processing the resultset when the message arrives, and then
continues to use the connection without fetching or cancelling the
pending results, you would see an invalid-cursor-state error on the
next query.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page