Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid problem of batch std::vector<ocilib::Date > date display. #349

Open
MagicXran opened this issue Jun 26, 2023 · 4 comments
Open

Invalid problem of batch std::vector<ocilib::Date > date display. #349

MagicXran opened this issue Jun 26, 2023 · 4 comments

Comments

@MagicXran
Copy link

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:

image

@MagicXran
Copy link
Author

Is it because ocilib::Date has no corresponding copy constructor?

@MagicXran
Copy link
Author

hello? Is anybody here?

@vrogier
Copy link
Owner

vrogier commented Apr 17, 2024

Hi,

I will investigate this issue prior the release of v4.7.7

Regards,

Vincent

@vrogier
Copy link
Owner

vrogier commented Apr 17, 2024

linked to #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants