sijms / go-ora

Pure go oracle client
MIT License
767 stars 168 forks source link

Use struct with Select many rows query #551

Closed dipeshhkc closed 2 months ago

dipeshhkc commented 2 months ago

Hi. Thank you for this library.

I am using struct with tag for BEGIN SELECT id,name INTO :id,:name FROM store WHERE id:id; end and using ExecContext command. This is working fine.

type storeArg struct{
   Id string `db:"name=id,size=50,dir=inout"`
   Name string `db:"name=name,size=50,dir=out`
}

How can I use struct if the SELECT is returning multiple rows? LIKE Getting all stores; SELECT id,name FROM store

sijms commented 2 months ago

database/sql doesn't support this feature so you should try it using package directly

conn, err := go_ora.NewConnection(den)
err = conn.Open()
rows, err := conn.QueryContext(,,,)
defer rows.Close()
.
.
.
dipeshhkc commented 2 months ago

Does go_ora QueryContext support struct argument? Do you have an example implementation?

sijms commented 2 months ago

you should cast driver.Rows to *DataSet or see examples/query_to_struct