Koka / odbc-rs

Rust ODBC FFI binding
MIT License
103 stars 31 forks source link

New Beginner: top level return for values example. #152

Closed DavidWhit closed 4 years ago

DavidWhit commented 4 years ago
 match stmt.exec_direct(&sql_text)? {
        Data(mut stmt) => {
            let cols = stmt.num_result_cols()?;
            while let Some(mut cursor) = stmt.fetch()? {
                for i in 1..(cols + 1) {
                    match cursor.get_data::<&str>(i as u16)? {
                        Some(val) => print!(" {}", val),
                        None => print!(" NULL"),
                    }
                }
                println!("");
            }
        }
        NoData(_) => println!("Query executed, no data returned"),
    }

That makes sense but If I think I have literally hit the wall on this. It's rather difficult at least being a beginner in rust to get the return value top level vs just printing/executing it. In a way I can still do clean up steps to reset params and close cursor. Can anyone help in this regard. Just to see how to go about it would be great. I looked at combinators to achieve this with no success because Data and NoData on ResultSetState

DavidWhit commented 4 years ago

I have no idea what I was thinking... I got caught up in the mechanics of rust error handling vs just doing something simple.