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

DPI-1020 #8

Closed
aleksmelnikov opened this issue Oct 2, 2018 · 2 comments
Closed

DPI-1020 #8

aleksmelnikov opened this issue Oct 2, 2018 · 2 comments

Comments

@aleksmelnikov
Copy link

aleksmelnikov commented Oct 2, 2018

My Cargo.toml:

[dependencies]
oracle = "*"

My code:

extern crate oracle;
use oracle::{Connection, Error, Result};

fn sql()-> Result<()> {

// Connect to a database.
let conn = Connection::connect("scott", "tiger", "//base/base", &[])?;

let sql = "select ename, sal, comm from emp where deptno = :1";

// Select a table with a bind variable.
println!("---------------|---------------|---------------|");
let rows = conn.query(sql, &[&30])?;
for row_result in &rows {
    let row = row_result?;
    // get a column value by position (0-based)
    let ename: String = row.get(0)?;
    // get a column by name (case-insensitive)
    let sal: i32 = row.get("sal")?;
    // Use `Option<...>` to get a nullable column.
    // Otherwise, `Err(Error::NullValue)` is returned
    // for null values.
    let comm: Option<i32> = row.get(2)?;

    println!(" {:14}| {:>10}    | {:>10}    |",
             ename,
             sal,
             comm.map_or("".to_string(), |v| v.to_string()));
}

// Another way to fetch rows.
// The rows iterator returns Result<(String, i32, Option<i32>)>.
println!("---------------|---------------|---------------|");
let rows = conn.query_as::<(String, i32, Option<i32>)>(sql, &[&10])?;
for row_result in &rows {
    let (ename, sal, comm) = row_result?;
    println!(" {:14}| {:>10}    | {:>10}    |",
             ename,
             sal,
             comm.map_or("".to_string(), |v| v.to_string()));
}

Ok(())
}


fn main() {
    match sql() {
        Ok(_) => {},
        Err(error) => { println!("{:?}", error); }
    }
}

The code is compiled ok. I am compiling to the windows gnu target:

cargo build --release --target i686-pc-windows-gnu

But the execution result is:
DpiError(DbError { code: 0, offset: 0, message: "DPI-1020: version 3.0 is not supported by ODPI-C library version 2.4", fn_name: "dpiContext_create", action: "check version" })

@kubo
Copy link
Owner

kubo commented Oct 2, 2018

Sorry, I failed to publish oracle 0.1.2. I released 0.2.0. Could you try it?

@aleksmelnikov
Copy link
Author

With the new version the error is gone. Thank you.

@kubo kubo closed this as completed Oct 2, 2018
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