Trait oracle_sql_tools::PrepData

source ·
pub trait PrepData<T: FormatData> {
    type Prep;

    // Required method
    fn prep_data(self, connection: Connection) -> Self::Prep;
}
Expand description

A trait to prepare either a vector or a 2-dimensional vector for a SQL query

The trait either returns statements::PreppedRowData or statements::PreppedGridData respectively

Using a vector to select specific columns from a table:

let conn: oracle::Connection = match Connection::connect("<USERNAME>", "<PASSWORD>", "<IP ADDRESS>")?; 

let col_names: Vec<&str> = vec!["Employee ID", "Name", "Job Title", "Department", "Business Unit"];

let table_data: Vec<Vec<Option<String>>> = col_names.prep_data(conn).select("MY_TABLE")?;

Using a 2-dimensional vector to insert data:

let conn: oracle::Connection = match Connection::connect("<USERNAME>", "<PASSWORD>", "<IP ADDRESS>")?; 

let data: Vec<Vec<String>> = vec![
    vec!["ColA".to_string(), "ColB".to_string(), "ColC".to_string()],
    vec!["A1".to_string(), "B1".to_string(), "C1".to_string()],
    vec!["A2".to_string(), "B2".to_string(), "C2".to_string()],
    vec!["A3".to_string(), "B3".to_string(), "C3".to_string()],
];
 
data.prep_data(conn).insert("MY_TABLE")?;
Ok(())

Required Associated Types§

Required Methods§

source

fn prep_data(self, connection: Connection) -> Self::Prep

Implementations on Foreign Types§

source§

impl<T: FormatData> PrepData<T> for Vec<Vec<T>>

§

type Prep = PreppedGridData

source§

fn prep_data(self, connection: Connection) -> Self::Prep

source§

impl<T: FormatData> PrepData<T> for Vec<T>

§

type Prep = PreppedRowData

source§

fn prep_data(self, connection: Connection) -> Self::Prep

Implementors§