Comments (8)
I don't have SQL Server 2008. Let me find one, so I can investigate this. But,
please, send the change, if you like. Thank you.
Alex
Original comment by [email protected]
on 22 Aug 2013 at 7:01
- Changed state: Accepted
from odbc.
Luke,
I issued these
select cast('20151225' as datetime)
select cast('20151225' as datetime2)
and here is what SQLDescribeCol returns
datetime : sqltype=93 size=23 decimal=3
datetime2: sqltype=-9 size=27 decimal=0
so datetime2 is returned as just SQL_WVARCHAR (it is a simple string). Do you
see things any different?
As to parameters, I didn't try anything. Instead I have found this
http://stackoverflow.com/questions/6256302/how-to-bind-a-value-to-a-stored-proc-
parameter-of-type-datetime27-using-odbc?rq=1
which kind of repeat what you said. datetime parameter code is already has some
hardcoding, I am not sure what to do until I se what your real problem is.
I will wait for you to send some code before decideing what to do next.
Alex
Original comment by [email protected]
on 23 Aug 2013 at 1:37
from odbc.
Alex,
Thanks for looking into this. I think that your driver is returning datetime2
as a "SQL_WVARCHAR" because you are using an older version of SQL Native Client
that doesn't support datetime2. Try upgrading to a more recent version of SQL
Native Client. You can try:
http://www.microsoft.com/en-us/download/details.aspx?id=35580 (Click on
"Download" and then ENU\x64\sqlncli.msi Then set your connection string to
include: "Driver={SQL Server Native Client 11.0}" After completing that,
SQLDescribeCol should report SQL_TYPE_TIMESTAMP.
I read the stackoverflow post and I did something very similar. In param.go in
the "time.Time" case I added:
size = 27 // 20 + s (the number of characters in the yyyy-mm-dd
hh:mm:ss[.fff...] format, where s is the seconds precision).
decimal = 7 //Setting to maximum possible fraction of a second -- cannot
determine how to read this from api.SQLDescribeParam
I also added a check after the switch to only set the decimal and size if they
were not set in the switch. I have attached the file. I will submit a change
request if you think it looks good.
Original comment by [email protected]
on 28 Aug 2013 at 12:50
Attachments:
from odbc.
Luke,
This https://codereview.appspot.com/13270047/ is to fetch datatime2 types from
the server. Please, review.
I will do parameter handling later
Alex
Original comment by [email protected]
on 30 Aug 2013 at 6:30
from odbc.
Reviewed the change to the tests.
Original comment by [email protected]
on 3 Sep 2013 at 4:03
from odbc.
Luke,
I have this test:
diff -r fdeace4e5288 mssql_test.go
--- a/mssql_test.go Wed Sep 04 16:49:55 2013 +1000
+++ b/mssql_test.go Wed Sep 04 17:27:08 2013 +1000
@@ -965,3 +965,53 @@
exec(t, db, "drop table dbo.temp")
}
+
+// https://code.google.com/p/odbc/issues/detail?id=14
+func TestMSSQLDatetime2Param(t *testing.T) {
+ db, sc, err := mssqlConnect()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer closeDB(t, db, sc, sc)
+
+ if !is2008OrLater(db) {
+ t.Skip("skipping test; needs MS SQL Server 2008 or later")
+ }
+
+ db.Exec("drop table dbo.temp")
+ exec(t, db, "create table dbo.temp (dt datetime2)")
+
+ expect := time.Date(2007, 5, 8, 12, 35, 29, 1234567e2, time.Local)
+ _, err = db.Exec("insert into dbo.temp (dt) values (?)", expect)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var got time.Time
+ err = db.QueryRow("select top 1 dt from dbo.temp").Scan(&got)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if expect != got {
+ t.Fatalf("expect %v, but got %v", expect, got)
+ }
+
+ exec(t, db, "drop table dbo.temp")
+}
+
And it is not failing regardless if I make changes to param.go or not. Do you
have a reproducible test that is broken. Thank you.
Alex
Original comment by [email protected]
on 4 Sep 2013 at 7:30
from odbc.
Luke, how about this https://codereview.appspot.com/14426055/ ?
Alex
Original comment by [email protected]
on 14 Oct 2013 at 3:01
- Changed state: Started
from odbc.
This issue was closed by revision d05da338d8c0.
Original comment by [email protected]
on 21 Oct 2013 at 12:19
- Changed state: Fixed
from odbc.
Related Issues (20)
- signal 13 received but handler not on signal stack HOT 4
- Low max message length HOT 3
- Add tags to the repo HOT 1
- Implement QueryerContext interface HOT 1
- Implement RowsColumnTypeDatabaseTypeName HOT 1
- error when build from linux HOT 2
- only half of unicode string is inserted.
- Issue with Unixodbc-2.3.7 for master and for_issue_88 branch HOT 1
- 向 varchar字段保存中文中会被截断 HOT 8
- Maintain releases HOT 5
- The package is returning a panic instead of an error HOT 4
- Issues with parametrized queries Windows/DuckDB HOT 2
- abount microsoft access long binary data type HOT 1
- Unrecognized Data Type on Column
- random errors when doing the db.query using Denodo odbc driver HOT 1
- Does this package support `-buildmode=c-shared` HOT 1
- Have error `api/api_unix.go:15:11: fatal error: 'sql.h' file not found` HOT 1
- Error : unrecognized import path "golang.zx2c4.com/go118/netip" HOT 2
- connect db2 when column is NULL, parsing data error execution an error occurred is {wrong column #1 length 4294967295 returned, 16 expected} HOT 3
- (duckdb ODBC) Cannot Insert INTEGER HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odbc.