How do i convert from sql decimal type to double WITHOUT casting the underlying database with a query as this answer suggests. I am on MySQL and casting from decimal(20,8) to real causes errors. I am using mysql-connector c++ and it loads and runs queires fine but i cannot conver the data from the mysql-connector format to that of c++.
I am using mysql 5.1.63 hosted on linux, while running code c++ from a different linux machine as well as well
I don’t have any experience using the standard C++ driver for MySQL (MySQL Connector/C++). However, I have used the MySQL++ driver.
The documentation for the MySQL Connector/C++ is pretty lacking. However, it seems to look as if it tries to stick to the JDBC API.
You can view the documentation for JDBC on the Oracle site.
I’m guessing to convert the value to double is fairly simple:
Edit:
Now you say the
doubleis being converted properly, but it isn’t being inserted into yourvector<double>properly.Try the following DIRECTLY after your loop:
Edit:
The
forloop prints everything successfully. So we know the doubles are being added to thevector<double>correctly.It sounds like you are trying to copy your
vector<double>somewhere, but aren’t doing it properly.Are you returning this from a function?
Edit:
Problem is now solved. The
vectorissue was elsewhere.