Invalid problem of batch std::vector<ocilib::Date > date display.
MagicXran opened this issue · comments
Write the code as follows, please focus on the roll_change_times variable.
void rollchan(std::vector<ocilib::ostring>& roll_ids, std::vector<ocilib::Date> roll_change_times, std::vector<float>& roll_diameters, std::vector<ocilib::ostring>& roll_locations, std::vector<ocilib::ostring>& roll_kinds)
{
try
{
auto& db = DB::OracleDB::OracleConnectionPool::getOracleInstance();
auto conn = db.getConnection();
const int StrMaxSize = 20;
ocilib::Statement stmt(conn);
//conn.SetAutoCommit(true);
stmt.Prepare("INSERT INTO ROLL_CHANGES (ROLL_ID,ROLL_LOCATION,ROLL_KIND,ROLL_DIAMETER,ROLL_CHANGE_TIME) VALUES (:ids,:locs,:kinds,:dia,:time)");
stmt.SetBindArraySize(roll_ids.size());
stmt.Bind(":ids", roll_ids, StrMaxSize, ocilib::BindInfo::In);
stmt.Bind(":locs", roll_locations, StrMaxSize, ocilib::BindInfo::In);
stmt.Bind(":kinds", roll_kinds, StrMaxSize, ocilib::BindInfo::In);
stmt.Bind(":dia", roll_diameters, ocilib::BindInfo::In);
stmt.Bind(":time", roll_change_times, ocilib::BindInfo::In);
stmt.ExecutePrepared();
conn.Commit();
std::cout << "row processed : " << stmt.GetAffectedRows() << std::endl;
}
catch (const std::exception& e)
{
cerr << "err: " << e.what() << endl;
}
}
//main
std::vector<ocilib::ostring> roll_ids{ "1","3","2","4" };
std::vector<ocilib::ostring> roll_locations{ "top","lo","t","er","666" };
std::vector<ocilib::ostring> roll_kinds{ "w","b","x","er" ,"666" };
// Is the date pointer displayed in roll_change_times null? Why is this?
std::vector<ocilib::Date> roll_change_times(4, ocilib::Date("2022-12-24 12:38:44", "yyyy-MM-dd HH24:mi:ss"));
std::vector<float> roll_diameters{ 1203.44f,333.f,555.f,55.67f ,555.0f };
rollchan(roll_ids, roll_change_times, roll_diameters, roll_locations, roll_kinds);
The following are the stored results? Confused 0002-11-30:
Is it because ocilib::Date has no corresponding copy constructor?
hello? Is anybody here?
Hi,
I will investigate this issue prior the release of v4.7.7
Regards,
Vincent
linked to #351