pacman82/odbc-api

different parameter types as array

Closed this issue · 4 comments

Hello, I want to pass different types of InputParameters with Vec<Box<dyn InputParameter>> but ParameterCollection isn't implemented for it. Is it possible to do this?

Hello, thanks for your issue. Do I understand your usecase correctly, that you want to pass an arbitrary number of abitrary typed input parameters to a query? If so I fear you might be right and there is right now no way to do this. Since ParameterCollection is already implemented for &[T: InputParmeter] the arbitrary number part is already covered. Implementing InputParameter for Box<dyn InputParameter> should take care of the arbitrary type side of things.

Give me a few minutes to explore this. If this works out you can expect a release soon.

FYI: If you want to read parameters from the command line, just use String and leave the conversion to the ODBC driver. See:

let params: Vec<_> = parameters

Released version 0.19.6 with Box<dyn InputParameter> implementing InputParameter. Also the module level documentation for parameteres has been updated (https://docs.rs/odbc-api/0.19.6/odbc_api/parameter/index.html#passing-an-input-parameters-with-dynamic-type).

Wow very fast. Thank you a lot, this helped me so much!