-
Notifications
You must be signed in to change notification settings - Fork 375
Open
Description
I am running the oracle docker on my machine & try to create the table but its giving error " Create tables failed ORA-00922: missing or invalid option" @klaidliadon
I am using the code gorp read.me
func initDb() *gorp.DbMap {
connectionString := "oracle://sys:jaw@localhost:1521/XE"
db, err := sql.Open("oracle", connectionString)
checkErr(err, "sql.Open failed")
err = db.Ping()
if err != nil {
panic(fmt.Errorf("error pinging db: %w", err))
}
// construct a gorp DbMap
dbmap := &gorp.DbMap{Db: db, Dialect: gorp.OracleDialect{}}
dbmap.AddTableWithName(Product{}, "products").SetKeys(true, "Id")
// create the table. in a production system you'd generally
// use a migration tool, or create the tables via scripts
err = dbmap.CreateTablesIfNotExists()
checkErr(err, "Create tables failed")
return dbmap
}
type Product struct {
Id int64 `db:"product_id, primarykey, autoincrement"`
Price int64 `db:"unit_price"`
IgnoreMe string `db:"-"`
}
In same way Insert data is also not working, Error "no table found for type: product"
p1 := &Product{9, 5, "Sugar"}
err = dbmap.Insert(p1)
But select query is working & giving correct result
count, err := dbmap.SelectInt("select count(*) from products")
checkErr(err, "select count(*) failed")
log.Println("Rows after inserting:", count)
var productsData []products
_, err = dbmap.Select(&productsData , "select * from products order by id")
Metadata
Metadata
Assignees
Labels
No labels