Comments (12)
Please, provide small program to demonstrate the problem. Thank you.
Alex
Original comment by [email protected]
on 11 Apr 2014 at 7:35
- Changed state: WaitingForReply
from odbc.
[deleted comment]
from odbc.
Error: sql: Scan error on column index 4: unsupported driver -> Scan pair:
<nil> -> *string
Query: SELECT TOP 10 ROW_NUMBER() OVER(ORDER BY SSN_NO), SSN_NO,
CURR_STATION, RESULT, ISNULL(FAILCODE, '')
FROM SFC_SSN(NOLOCK)
WHERE WONO=?
Condition: [NE03300016]
the column FAILCODE type is: NVARCHAR(30)
Original comment by [email protected]
on 11 Apr 2014 at 8:35
from odbc.
SQL is nice, but I still don't see what the problem is. Please provide small Go
program I can run to see your problem. Show what you program displays and
explain why its output is wrong. Hopefully I will be able to run your program
here.
Thank you.
Alex
Original comment by [email protected]
on 11 Apr 2014 at 11:05
from odbc.
package main
import (
_ "./odbc"
"database/sql"
"fmt"
"reflect"
)
const (
ConnectString = "driver={sql server};server=servername;database=database;uid=sa;pwd=password"
)
func FetchAllRowsPtr(query string, struc interface{}, cond ...interface{})
*[]interface{} {
db, err := sql.Open("odbc", ConnectString)
if err != nil {
fmt.Printf("sql.Open Error: %v\n", err)
panic(err)
}
defer db.Close()
stmt, err := db.Prepare(query)
if err != nil {
fmt.Printf("db.Prepare Error: %v\n", err)
panic(err)
}
defer stmt.Close()
rows, err := stmt.Query(cond...)
if err != nil {
fmt.Printf("stmt.Query Error: %v\n", err)
panic(err)
}
defer rows.Close()
result := make([]interface{}, 0)
s := reflect.ValueOf(struc).Elem()
leng := s.NumField()
onerow := make([]interface{}, leng)
for i := 0; i < leng; i++ {
onerow[i] = s.Field(i).Addr().Interface()
}
for rows.Next() {
err = rows.Scan(onerow...)
if err != nil {
fmt.Printf("Error: %v\nQuery: %v\nCondition: %v\n", err, query, cond)
panic(err)
}
result = append(result, s.Interface())
}
return &result
}
type WoDetail struct {
Index int
Serial string
Curr string
Result string
Failcode string
}
func getdate(wono string) {
wo_ls := FetchAllRowsPtr(
`SELECT TOP 10 ROW_NUMBER() OVER(ORDER BY SSN_NO), SSN_NO,
CURR_STATION, RESULT, ISNULL(FAILCODE, '')
FROM SFC_SSN(NOLOCK)
WHERE WONO=?`, new(WoDetail), wono)
fmt.Printf("values: %v\n", wo_ls)
}
func main() {
getdate('NE03300016')
}
// at the line 47, will occurred the error
Original comment by [email protected]
on 11 Apr 2014 at 2:31
from odbc.
Thank you for the code. I will try it.
Alex
Original comment by [email protected]
on 12 Apr 2014 at 2:26
from odbc.
I can see your problem now. Here https://codereview.appspot.com/87490043/ is
the fix. Please, review. Thank you.
Alex
Original comment by [email protected]
on 14 Apr 2014 at 4:14
from odbc.
Original comment by [email protected]
on 14 Apr 2014 at 4:15
- Changed state: Started
from odbc.
I can't link the address: https://codereview.appspot.com/87490043/
Did you write a short fix at here, thanks.
Original comment by [email protected]
on 14 Apr 2014 at 4:28
from odbc.
Sure. Please, see a.diff file attached.
Alex
Original comment by [email protected]
on 14 Apr 2014 at 4:32
Attachments:
from odbc.
Issue 41 has been merged into this issue.
Original comment by [email protected]
on 28 Apr 2014 at 11:33
from odbc.
This issue was closed by revision a8ac5d333051.
Original comment by [email protected]
on 6 May 2014 at 1:56
- Changed state: Fixed
from odbc.
Related Issues (20)
- DB2 on Windows Server 2012 R2 connect but truncate data retreived HOT 1
- DB2 for i: Simple select with empty ResultSet locks table HOT 1
- Compile errors when building from Windows OS with GOOS=linux HOT 2
- an error of SQL syntax error HOT 1
- Panic when binding `varchar`/`string` types: slice bounds out of range [:668] with capacity 256 HOT 3
- memory leak using rows.next() HOT 7
- 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
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.