Forum Stats

  • 3,875,844 Users
  • 2,266,975 Discussions


Select COUNT(*), SUM, MIN, MAX returns Double starting with Oracle Client

wehnerr Member Posts: 3
edited May 5, 2015 11:19AM in ODBC

Current C++ Application using ODBC API calling Oracle Client 10g (all versions), 11gR1 (v11.1.0.6) returns a LONG (4-byte integer) for "SELECT COUNT(*) from tablename"

Same with MIN, MAX, SUM.  If original column is a LONG (4-byte integer) or NUMBER(12,0), SUM, MIN, MAX for sure should return same data type.

If you Change Oracle client to 11gR1 (v11.1.0.7) or higher (11.2.x.y etc) and that same statement returns a DOUBLE (8-byte floating value equivalent to oracle NUMBER data type).

Since the backend DB was not changed in the testing (same version), there must be a client side setting (I presume) that has changed the default behaviour of this Aggregate SQL function to return a double rather than a long. I'm hoping to find such a setting that I can either set programmatically through an ODBC API call, or in the Oracle Client configuration itself.

I know I can use SQL CAST to make it an INT; SELECT CAST(COUNT(*) AS NUMBER(12,0)) FROM tablename but that means making my generic ODBC code Database specific, as SQL Server doesn't have that data type.

Note: given that I use ODBC, I've written alot of generic C++ code supporting the return value as LONG, as that is how it's been for 10 years via ODBC. I'd like to maintain that if possible without having to write ORACLE specific code within my applications.

This discussion has been closed.