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

time.Time shows <nil> even if the value is present in the DB #267

Open
GaganTM opened this issue Sep 19, 2019 · 7 comments
Open

time.Time shows <nil> even if the value is present in the DB #267

GaganTM opened this issue Sep 19, 2019 · 7 comments

Comments

@GaganTM
Copy link

GaganTM commented Sep 19, 2019

When I execute the select statement 1st time date value will be available.
When I execute the same select statement 2nd time its show value in the terminal.

@tgulacsi
Copy link
Collaborator

What is the query? Please show us the relevant code?

@GaganTM
Copy link
Author

GaganTM commented Sep 20, 2019

I have used below query for fetch the data.
select invoice_id,num,trunc(invoice_date),vendor_name,description,status from XXX_Table

But I am facing problem in date

@GaganTM
Copy link
Author

GaganTM commented Sep 20, 2019

Sometimes I am facing issue in fetching float64 data type

@GaganTM
Copy link
Author

GaganTM commented Sep 20, 2019

For Float data type I am getting the error in item_id it shows
Scan error : value is found instead of Float data type

i am using below query
select po_id,po_line_id,line_num,unit_price,quantity,item_description,item_id,category_id,unit_meas_lookup_code from po_table

@GaganTM
Copy link
Author

GaganTM commented Sep 20, 2019

func GetPoLineDeatils(poheaderid float64) []POLineDeatils {
var polinedata []POLineDeatils

env, srv, ses, err := ora.NewEnvSrvSes("test/[email protected]:1521/XE")
if err != nil {
	fmt.Println(err)
	return polinedata
}
defer env.Close()
defer srv.Close()
defer ses.Close()

// pohea.

stmtQry, err := ses.Prep(fmt.Sprintf(
	"select po_id,po_line_id,line_num,unit_price,quantity,item_description,item_id,category_id,unit_meas_lookup_code from po_table where po_id=%v", poheaderid))
defer stmtQry.Close()
if err != nil {
	// panic(err)
	fmt.Println(err)
}
rset, err := stmtQry.Qry()
if err != nil {
	// panic(err)
	fmt.Println(err)
}
for i := 0; rset.Next(); i++ {
	// fmt.Println(rset.Row[0].(float64), rset.Row[1].(float64), rset.Row[2].(string), rset.Row[3].(string), rset.Row[4].(string), rset.Row[5].(string), rset.Row[6].(string), rset.Row[7].(string), rset.Row[8].(string))
	fmt.Println(rset.Row[0].(float64))
	fmt.Println(rset.Row[1].(float64))
	fmt.Println(rset.Row[2].(float64))
	fmt.Println(rset.Row[3].(float64))
	fmt.Println(rset.Row[4].(float64))
	fmt.Println(rset.Row[5].(string))
	fmt.Println(rset.Row[6].(float64))
	fmt.Println(rset.Row[7].(float64))
	fmt.Println(rset.Row[8].(string))

	// if

	polinedata = append(polinedata, POLineDeatils{PoHeaderID: rset.Row[0].(float64), PoLineID: rset.Row[1].(float64), LineNum: rset.Row[2].(float64), UnitPrice: rset.Row[3].(float64), Quantity: rset.Row[4].(float64), ItemDescription: rset.Row[5].(string), ItemID: rset.Row[6].(float64), CategoryID: rset.Row[7].(float64), UnitMeasLookupCode: rset.Row[8].(string)})

}
if err := rset.Err(); err != nil {
	fmt.Println(err)
	// panic(err)
}

return polinedata

}

@tgulacsi
Copy link
Collaborator

tgulacsi commented Sep 20, 2019 via email

@GaganTM
Copy link
Author

GaganTM commented Dec 4, 2019

Thanks for the suggestion.
I will try it

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