Hello,
Newbie in Rust here. I'm trying to make a program that makes queries from Actian database and creates excel-files of the result.
I need to make two queries, the first query will get some supplier-id:s and the second query selects some product data for each supplier and result should end up in excel files, one file per supplier.
I've tried hacking the examples on odbc_api::guide and managed to get a connection to the database.
How do I assign variable xx the value of first column in query result set. I only get error E0599 using fetch() and don't know how to fix it.
Here's my code snippet:
// Define xx before the if let block
let mut xx: Option = None;
// Fetch the first row from the result set.
if let Some(result_set) = result_set1 {
if let Some(row) = result_set.fetch()? {
// Column 1 contains the value
xx = Some(row.get_string(1)?);
println!("Value: {}", xx.as_ref().unwrap());
}
Whenever you need the results from one database query as input for another database query, it's more efficient to let the database handle it for you. In SQL databases you would do it with JOIN.
As for your specific error, please show the full error returned by the compiler. It'll be much easier to help you that way.
I know it is more efficient to let the database join the result, but I find it easier to loop trough the results and do my outputting in files if I do double queries.
Compiler says:
error[E0599]: no method named fetch found for struct CursorImpl in the current scope
--> src\main.rs:25:39
|
25 | if let Some(row) = result_set.fetch()? {
| ^^^^^ method not found in CursorImpl<StatementRef<'_>>