0

I'm creating PostgreSQL database client that ought to work as substitute for SQL Server client. Both clients are written in C++. One of the supported operation is bulk copy from given instance of class containing std::string ReadChunk() method.

For now I use libpq functions:

PQexec(connection, "COPY tablename FROM STDIN");
while(reader.HasNext()) {
     PQputCopyData(connection, reader.ReadChunk().c_str());
}
PQputCopyEnd(connection);

But turns out that I should also be able to truncate too long varchars and insert NULL between two consecutive \t if they are representing nullable column. Is there any way to perform this conversion on the database side, writing C triggers or something similar? Or should I implement argument parsing on the client side, something like SQL Server bcp_bind?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
SzymonPajzert
  • 692
  • 8
  • 18

1 Answers1

0

My implementation pushed basic data processing on database client. It seemed to be a good solution, since data source was database independent and it traversed read data only once - I needed only truncation and NULL insertion.

So final solution consisted of class RowReader with methods bool HasNext() and NextRow(CRow&) reading next row to the table representation and abstract RowSender with implementations for every database.

SzymonPajzert
  • 692
  • 8
  • 18