本文整理汇总了Golang中database/sql/driver.RowsAffected函数的典型用法代码### 示例。如果您正苦于以下问题:Golang RowsAffected函数的具体用法?Golang RowsAffected怎么用?Golang RowsAffected使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。

在下文中一共展示了RowsAffected函数的15个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: Exec

func (stmt *cypherStmt) Exec(args []driver.Value) (driver.Result, error) {
    if stmt.c.transaction != nil {
        err := stmt.c.transaction.query(stmt.query, args)
        // TODO add counts and error support
        return driver.RowsAffected(0), err
    }
    rows, err := stmt.Query(args)
    if rows != nil {
        defer rows.Close()
    }
    // TODO add counts and error support
    return driver.RowsAffected(0), err
}

开发者ID:slowteetoe,项目名称:presagio,代码行数:13,代码来源:statement.go

示例2: exec

func (c *conn) exec(stmt parser.Statement, args []driver.Value) (driver.Result, error) {
    rows, err := c.query(stmt, args)
    if err != nil {
        return nil, err
    }
    return driver.RowsAffected(len(rows.rows)), nil
}

开发者ID:Jaekyun,项目名称:cockroach,代码行数:7,代码来源:conn.go

示例3: execInsert

func (s *fakeStmt) execInsert(args []driver.Value) (driver.Result, error) {
    db := s.c.db
    if len(args) != s.placeholders {
        panic("error in pkg db; should only get here if size is correct")
    }
    db.mu.Lock()
    t, ok := db.table(s.table)
    db.mu.Unlock()
    if !ok {
        return nil, fmt.Errorf("fakedb: table %q doesn't exist", s.table)
    }

    t.mu.Lock()
    defer t.mu.Unlock()

    cols := make([]interface{}, len(t.colname))
    argPos := 0
    for n, colname := range s.colName {
        colidx := t.columnIndex(colname)
        if colidx == -1 {
            return nil, fmt.Errorf("fakedb: column %q doesn't exist or dropped since prepared statement was created", colname)
        }
        var val interface{}
        if strvalue, ok := s.colValue[n].(string); ok && strvalue == "?" {
            val = args[argPos]
            argPos++
        } else {
            val = s.colValue[n]
        }
        cols[colidx] = val
    }

    t.rows = append(t.rows, &row{cols: cols})
    return driver.RowsAffected(1), nil
}

开发者ID:anuvazhayil,项目名称:HelloWorld_32bitOS,代码行数:35,代码来源:fakedb_test.go

示例4: Exec

func (c *conn) Exec(stmt string, args []driver.Value) (driver.Result, error) {
    rows, err := c.Query(stmt, args)
    if err != nil {
        return nil, err
    }
    return driver.RowsAffected(len(rows.rows)), nil
}

开发者ID:XisiHuang,项目名称:cockroach,代码行数:7,代码来源:conn.go

示例5: Exec

func (cn *Conn) Exec(query string, args []interface{}) (driver.Result, error) {
    if len(args) == 0 {
        err := cn.p.SimpleQuery(query)
        if err != nil {
            return nil, err
        }

        var serr error
        for {
            m, err := cn.p.Next()
            if err != nil {
                return nil, err
            }

            switch m.Type {
            case 'E':
                serr = m.Err
            case 'Z':
                return driver.RowsAffected(0), serr
            }
        }
    } else {
        stmt, err := cn.Prepare(query)
        if err != nil {
            return nil, err
        }

        return stmt.Exec(args)
    }

    panic("not reached")
}

开发者ID:bhuvan,项目名称:go-sql-test,代码行数:32,代码来源:conn.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng