Hi all, I have a function in my Postgres database that returns a setof refcursors ( 4 ), how can I fetch the data without knowing in advance the names of the refcursors , I’m thinking there must be a way of retrieving the cursor names programatically, hope this makes sense
import (
"database/sql"
"fmt"
"log"
_ "github.com/lib/pq"
)
const (
host = "ip address goes here"
port = 5432
user = "postgres"
password = "*********"
dbname = "*********"
)
func main() {
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
"password=%s dbname=%s sslmode=disable",
host, port, user, password, dbname)
db, err := sql.Open("postgres", psqlInfo)
if err != nil {
log.Fatal(err)
}
defer db.Close()
tx, err := db.Begin()
// This function returns 4 cursors
row := tx.QueryRow("SELECT public.spgetinvoicedata();")
var CursorName string
// This returns the name of the first cursor
err = row.Scan(&CursorName)
rows1, err := tx.Query("FETCH all from " + CursorName + ";" )
// There is now data in rows1
// How do I get the names of the other cursors
}