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

Invalid Input Number error #404

Closed
lvxiaorun opened this issue Jul 14, 2023 · 1 comment
Closed

Invalid Input Number error #404

lvxiaorun opened this issue Jul 14, 2023 · 1 comment

Comments

@lvxiaorun
Copy link

when query as this sql

select t1.sql_Id,t1.sql_text,t2.elapsed_time_total as elapsed_time,t2.executions_total as executions from dba_hist_sqltext t1 join
dba_hist_sqlstat t2 on t1.sql_id=t2.sql_id where t1.command_type=3

code example

rows, err := db.Query("select t1.sql_Id,t1.sql_text,t2.elapsed_time_total as elapsed_time,t2.executions_total as executions from dba_hist_sqltext t1 join \ndba_hist_sqlstat t2 on t1.sql_id=t2.sql_id where t1.command_type=3")
	if err != nil {
		panic(err)
	}
	var id, sql string
	var et, ex int
	for rows.Next() {
		err := rows.Scan(&id, &sql, &et, &ex)
		if err != nil {
			panic(err)
		}
	}
	if rows.Err() != nil {
		panic(rows.Err())
	}

the rows.Err() is not empty and like this

Invalid Input Number xxxxxxxxxxxxxxxxxxxxxxxxx

remark
golang version: 1.17.2
oracle version: 11g

@lvxiaorun lvxiaorun changed the title Invalid Input Numer error Invalid Input Number error Jul 14, 2023
@sijms
Copy link
Owner

sijms commented Jul 29, 2023

this code is working without errors
v2.7.10
go v1.18+
database 19c

package main

import (
	"database/sql"
	"fmt"
	_ "github.com/sijms/go-ora/v2"
	"os"
)

func Query(db *sql.DB) {
	rows, err := db.Query(`select t1.sql_Id,t1.sql_text,t2.elapsed_time_total as elapsed_time, t2.executions_total as executions 
from dba_hist_sqltext t1 inner join dba_hist_sqlstat t2 on t1.sql_id=t2.sql_id where t1.command_type=3`)
	if err != nil {
		panic(err)
	}
	var id, sql string
	var et, ex int
	for rows.Next() {
		err := rows.Scan(&id, &sql, &et, &ex)
		if err != nil {
			panic(err)
		}
	}
	if rows.Err() != nil {
		panic(rows.Err())
	}
}
func main() {
	conn, err := sql.Open("oracle", os.Getenv("DSN"))
	if err != nil {
		fmt.Println(err)
		return
	}
	defer conn.Close()
	Query(conn)
}

@sijms sijms closed this as completed Aug 12, 2023
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