steino / odbc

Automatically exported from code.google.com/p/odbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

MIN & MAX isn't working #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hey,

I'm using your ODBC driver with unixODBC on Ubuntu-Desktop 12.10 (64bit) to 
connect to a SAP Hana database. 
Unfortunately the MIN and MAX function doesn't work.
With isql I can query the following Statement:
SELECT "SalesOrder"."id", min("SalesOrderLineItem"."promisedate") FROM 
"Golang"."SalesOrder", "Golang"."SalesOrderLineItem" WHERE 
"SalesOrderLineItem"."salesorderid" = "SalesOrder"."id" Group BY 
"SalesOrder"."id" ORDER BY  "SalesOrder"."id" asc LIMIT 10 OFFSET 0

The result:
+------------+-----------------+
| id         | MIN(promisedate)|
+------------+-----------------+
| 1          | 2011-04-12      |
| 2          | 2012-06-16      |
| 3          | 2012-06-16      |
| 4          | 2012-04-24      |
| 5          | 2012-01-26      |
| 6          | 2011-12-18      |
| 7          | 2012-07-28      |
| 8          | 2011-07-28      |
| 9          | 2012-08-03      |
| 10         | 2011-10-17      |
+------------+-----------------+

In Go it just fills the id column, not the MIN one:
[id MIN(promisedate)] <nil>
[[1 ] [2 ] [3 ] [4 ] [5 ] [6 ] [7 ] [8 ] [9 ] [10 ]]

Any idea to solve this?

Best regards
Frank

(using,go1.0.3, unixodbc 2.2.14p2-5ubuntu4, unixodbc-dev 2.2.14p2-5ubuntu4, 
newest ODBC go package)

Original issue reported on code.google.com by frabl...@gmail.com on 13 Mar 2013 at 3:19

GoogleCodeExporter commented 9 years ago
I tried to use MIN/MAX here (I connect to ms sql server from linux using 
freetds-0.91), and it works just fine. Can you, please, show your Go code? 
Perhaps, I could give you instructions on how to diagnose the problem. Thank 
you.

Alex

Original comment by alex.bra...@gmail.com on 22 Apr 2013 at 12:27

GoogleCodeExporter commented 9 years ago
Try this SQL:
SELECT "SalesOrder"."id", min("SalesOrderLineItem"."promisedate") as 
minpromisedate FROM "Golang"."SalesOrder", "Golang"."SalesOrderLineItem" WHERE 
"SalesOrderLineItem"."salesorderid" = "SalesOrder"."id" Group BY 
"SalesOrder"."id" ORDER BY  "SalesOrder"."id" asc LIMIT 10 OFFSET 0

I named the min column.  See if that works for you.

Original comment by lukemaul...@gmail.com on 27 Apr 2013 at 6:39

GoogleCodeExporter commented 9 years ago
Hey,
sorry for my late answer. It was a problem with the datatype I was saving
the results to.
Your package works great :)

Original comment by frabl...@gmail.com on 2 May 2013 at 7:28

GoogleCodeExporter commented 9 years ago
Glad it works for you.

Alex

Original comment by alex.bra...@gmail.com on 3 May 2013 at 1:30