2

I have a postgresql table like

CREATE TABLE "T"
(
  "D" timestamp without time zone NOT NULL,
  "C" character(2) NOT NULL,
  CONSTRAINT "PK" PRIMARY KEY ("D", "C")
)
WITH (
  OIDS=FALSE
);

and insert into it with bucket nanodbc request. Like

int rowCount = 3;
m_apStatement.reset(new nanodbc::statement(m_connection));
prepare(*m_apStatement, “insert into T (D, C) values (?, ?)”);
char n[1000][2];
for (int i = 0; i < rowCount; i++)
{
    n[i][0] = 'a' + i;
    n[i][1] = 0;
}
std::vector<nanodbc::timestamp> dtBuf; …
statement.bind(0, &(dtBuf[0]), rowCount);
statement.bind_strings(1, reinterpret_cast<const char *>(n), 2, rowCount);
execute(*m_apStatement, rowCount);

I get “ОШИБКА: значение не умещается в тип character(2);” (“ERROR: value doesn’t fit into type character(2)”)

Increasing to character(9) in the database doesn't help. I saw logic like ODBCGetFieldDescription that reads length 255 and I see 255 in statement.impl->bind_len_or_null_[0].

Does somebody know a fix or workaround? I filled an issue https://github.com/nanodbc/nanodbc/issues/173 and maybe a supporter wrote that I use old version, 2.1 and there were some fixes regarding to strings. In the master branch. I use Visual Studio 2013 and it is not supported anymore there...

Postgresql 9.3.3, latest ODBC driver for it, Win 7 x64

Mikhail M
  • 929
  • 2
  • 10
  • 23

0 Answers0