array

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package array provides the array table-valued SQL function.

https://sqlite.org/carray.html

Example
sqlite3.AutoExtension(array.Register)

db, err := sqlite3.Open(":memory:")
if err != nil {
	log.Fatal(err)
}
defer db.Close()

stmt, _, err := db.Prepare(`
		SELECT name
		FROM pragma_function_list
		WHERE name like 'geopoly%' AND narg IN array(?)`)
if err != nil {
	log.Fatal(err)
}
defer stmt.Close()

err = stmt.BindPointer(1, [...]int{2, 3, 4})
if err != nil {
	log.Fatal(err)
}

for stmt.Step() {
	fmt.Printf("%s\n", stmt.ColumnText(0))
}
if err := stmt.Err(); err != nil {
	log.Fatal(err)
}
Output:

geopoly_regular
geopoly_overlap
geopoly_contains_point
geopoly_within
Example (Driver)
db, err := driver.Open("file:/test.db?vfs=memdb", array.Register)
if err != nil {
	log.Fatal(err)
}
defer db.Close()

rows, err := db.Query(`
		SELECT name
		FROM pragma_function_list
		WHERE name like 'geopoly%' AND narg IN array(?)`,
	sqlite3.Pointer([]int{2, 3, 4}))
if err != nil {
	log.Fatal(err)
}
defer rows.Close()

for rows.Next() {
	var name string
	err := rows.Scan(&name)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", name)
}
if err := rows.Err(); err != nil {
	log.Fatal(err)
}
Output:

geopoly_regular
geopoly_overlap
geopoly_contains_point
geopoly_within

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(db *sqlite3.Conn) error

Register registers the array single-argument, table-valued SQL function. The argument must be bound to a Go slice or array of ints, floats, bools, strings or byte slices, using sqlite3.BindPointer or sqlite3.Pointer.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL