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: Jeremy Livingston <jeremyjlivingston AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Using GROUP BY and COUNT
  • Date: Wed, 19 Dec 2012 15:58:18 -0500

The only reason that I asked about the driver is because that is the error
that I am receiving when I try to run my query with bsqlodbc:

bsqlodbc -S {server} -U {user} -P {pass} -D {db} <<< 'select count
(productCode) from Membership'

bsqlodbc: error -1: SQLConnect: SQL_ERROR: failed "[unixODBC][Driver
Manager]Data source name not found, and no default driver specified"

I'm not sure if there's configuration that I'm missing or what...but when I
connect with a DSN from the same server via the web, I don't have this
issue.


On Wed, Dec 19, 2012 at 3:51 PM, James K. Lowden <jklowden AT freetds.org>wrote:

> 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
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>




Archive powered by MHonArc 2.6.24.

Top of Page