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

ORA-00911: invalid character with go-ora and IN clause #854

Open
nenadnoveljic opened this issue Mar 30, 2023 · 1 comment
Open

ORA-00911: invalid character with go-ora and IN clause #854

nenadnoveljic opened this issue Mar 30, 2023 · 1 comment

Comments

@nenadnoveljic
Copy link

nenadnoveljic commented Mar 30, 2023

import ( "log" "github.com/jmoiron/sqlx" go_ora "github.com/sijms/go-ora/v2" )

connStr := go_ora.BuildUrl(HOST, PORT, SERVICE_NAME, USER, PASSWORD, map[string]string{})
db, err := sqlx.Open("oracle", connStr)
if err != nil {
log.Fatalf("open %s", err)
return
}
err = db.Ping()
if err != nil {
log.Fatalf("ping %s", err)
return
}
slice := []int{1}
query, args, err := sqlx.In("SELECT 1 FROM dual WHERE rownum IN (?)", slice)
if err != nil {
log.Fatalf("prepare %s", err)
}
_, err = db.Query(db.Rebind(query), args...)
if err != nil {
log.Fatalf("IN query %s", err)
}

IN query ORA-00911: invalid character

The same code works well with Godror.

nenadnoveljic added a commit to DataDog/datadog-agent that referenced this issue Mar 31, 2023
nenadnoveljic added a commit to DataDog/datadog-agent that referenced this issue Apr 6, 2023
@thomaskchan
Copy link

thomaskchan commented Apr 11, 2023

I ran into a similar issue, and I believe this is because the go-ora "oracle" driver doesn't have a default bind type.

I set this before the Rebind:

sqlx.BindDriver("oracle", sqlx.NAMED)

Otherwise, this can be fixed with #856.

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

No branches or pull requests

2 participants