Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return output of SQL statement #5

Open
GoogleCodeExporter opened this issue Oct 26, 2015 · 1 comment
Open

Return output of SQL statement #5

GoogleCodeExporter opened this issue Oct 26, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

This function should be added since it's very usefull to get the output of a 
SQL statement.

* * *
func (c *Conn) QueryOutput(statement string) (a []string, err os.Error) {
    query, err := c.Prepare(statement)
    if err != nil {
        return
    }
    defer query.Finalize()

    if err = query.Exec(); err != nil {
        return
    }

    var field string

    for {
        if ok := query.Next(); !ok {
            break
        }

        if err = query.Scan(&field); err != nil {
            return nil, err
        }
        a = append(a, field)
    }

    return
}
* * *

Original issue reported on code.google.com by raul....@sent.com on 1 Dec 2010 at 12:06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant