SQL数据库为BIGINT时,插入数据库出错type: unsupported type big.Int

admin87 · 2018-05-05 14:31:49 · 2182 次点击 · 大约8小时之前 开始浏览    置顶
这是一个创建于 2018-05-05 14:31:49 的主题,其中的信息可能已经有所发展或是发生改变。

rows,err := app.PLADB.Query("SELECT TOP 1 convert(bigint,ID) AS [FSourceInterID]  FROM History")
if err != nil {
    return
}
defer rows.Close()
var s interface{}

for rows.Next() {
    err = rows.Scan(&s)
    if err != nil {
        panic(err)
    }
    fmt.Printf("x is of type %T\n", s)
    fmt.Println(s)
}
log.Println(app.PLADB.Query("insert into t(id) values (?)",s))

查出来的是bigint类型。然后在插入时,出错 2018/05/05 14:29:34 sql: converting argument $1 type: unsupported type big.Int, a struct

以下是输出的类型与值 s is of type *big.Int 17121111112102

请指教,这个如何处理


有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

2182 次点击  
加入收藏 微博
2 回复  |  直到 2018-05-08 12:28:57
channel
channel · #1 · 7年之前

convert(bigint,ID) 是干嘛的?不转不行?

admin87
admin87 · #2 · 7年之前

找到解决法 了,就是取数据,把BIGINT转为INT64

谢谢

添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传