Skip to content

ODBC MSSQL bulk insert UNIQUEIDENTIFIER type does not work #4978

@solarobot

Description

@solarobot

HI,

I am using poco data to do bulk insert, while it falls into error when facing UNIQUEIDENTIFIER data type,
Tried std::string and Poco::UUID at code side, however not helped.

        int rows = 100000;
	std::vector<std::string> oids(rows);

	for (int i = 0; i < rows; ++i) {
		oids[i] = Poco::UUIDGenerator::defaultGenerator().createRandom().toString();
	}
	Statement stmt(*m_pSession);
	std::string query("CREATE TABLE ##Person (oid UNIQUEIDENTIFIER, FirstName NVARCHAR(MAX), BORN DATETIME, Age TINYINT)");
	stmt.executeDirect(query);

	int age = 42;
	std::vector<int> ageVec(rows, age);
	int count = -1;
	m_pSession->setFeature("autoBind", true);
	m_pSession->setFeature("autoExtract", true);
	*m_pSession << "select count(*) from ##Person;"s, Keywords::into(count), Keywords::now;
	*m_pSession << "INSERT INTO ##Person (oid) VALUES (?)"s,
		use(oids, bulk), Keywords::now;
	*m_pSession << "select count(*) from ##Person;"s, Keywords::into(count), Keywords::now;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions