I'm referring to rusoto_rds_data - Rust
Consider the following piece of code:
let x = Self::exec_stmt(
"SELECT \"hello world\"".to_string(),
Some(vec![SqlParameter {
name: Some("EntryName".to_string()),
value: Some(rusoto_rds_data::Field {
blob_value: None,
boolean_value: None,
double_value: None,
is_null: None,
long_value: None,
string_value: Some("hello world".to_string()),
}),
}]),
)
.sync();
println!("000 got: {:?}", x);
let x = Self::exec_stmt(
"SELECT @EntryName".to_string(),
Some(vec![SqlParameter {
name: Some("EntryName".to_string()),
value: Some(rusoto_rds_data::Field {
blob_value: None,
boolean_value: None,
double_value: None,
is_null: None,
long_value: None,
string_value: Some("hello world".to_string()),
}),
}]),
)
.sync();
println!("111 got: {:?}", x);
let x = Self::exec_stmt(
"SELECT @EntryName".to_string(),
Some(vec![SqlParameter {
name: Some("@EntryName".to_string()),
value: Some(rusoto_rds_data::Field {
blob_value: None,
boolean_value: None,
double_value: None,
is_null: None,
long_value: None,
string_value: Some("hello world".to_string()),
}),
}]),
)
.sync();
println!("222 got: {:?}", x);
I get output of:
000 got: Ok(ExecuteStatementResponse { column_metadata: None, generated_fields: None, number_of_records_updated: Some(
0), records: Some([[Field { blob_value: None, boolean_value: None, double_value: None, is_null: None, long_value: None
, string_value: Some("hello world") }]]) })
111 got: Ok(ExecuteStatementResponse { column_metadata: None, generated_fields: None, number_of_records_updated: Some(
0), records: Some([[Field { blob_value: None, boolean_value: None, double_value: None, is_null: Some(true), long_value
: None, string_value: None }]]) })
222 got: Err(Service(BadRequest("Named parameter syntax is invalid, input: @EntryName")))
get_db_wiki_entry_by_short_title "trig_circle_def" database error: Service(BadRequest("Named parameter syntax is inval
id, input: @EntryName"))
The problem here is that I don't know how to pass a parameter to SQL.
In the first example, it works when I hard code the "hello world" into the sql query.
In the second example, I am trying to pass it via "@EntryName" -- but I get NULL in return value.
In the last example, I'm trying to give the parameter the name "@EntryName" -- but am being told that that isinvalid.
What am I doing wrong?