At friday I've met a problem, that I don't know how to solve it.
I've a lot of lines of code which is using mysql++ (to be honest I don't
have much experience with this library). Mainly in code SQL is using
by calling SQL function with SQLQueryParams (insteed "INSERT"),
as you can look below.
The previous idea in architecture was to keep null value as zero or
" " (depends of type).
But now there was decision to store all null value as "null". And I tried
to find in the google how to do it painless
The invoking in C++ looks like:
std::string strQuery = "CALL MyFunction(%0q, %1q, %2q, %3q)";
mysqlpp::Query query = connection->query(strQuery);
// the type of strings are std::string
params << String1;
params << String2;
params << String3; // This string has value " ". I would like to
store it as null
params << String4;
I can not predict which String will have value " ", this situation that this is
String3 is only example.
Example procedure (of course it is more complicated... but this is good example
CREATE DEFINER=`root`@`localhost` PROCEDURE `MyFunction`(A_one VARCHAR(30),
A_two VARCHAR(30), A_three VARCHAR(30), A_four VARCHAR(30))
INSERT INTO myTable(one, two, three, four) VALUES(A_one, A_two , A_three ,
// and example of table
CREATE TABLE IF NOT EXISTS `myTable` (
`id` int(11) NOT NULL auto_increment,
`one` varchar(30) collate utf8_unicode_ci,
`two` varchar(30) collate utf8_unicode_ci,
`three` varchar(30) collate utf8_unicode_ci,
`four` varchar(30) collate utf8_unicode_ci,
) ENGINE=MyISAM default CHARSET=utf8 collate=utf8_unicode_ci;
So... that is the problem