/* Copyright (c) 2017, MariaDB Corporation. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301  USA
 */

// Bulk insert example from docs, requires the table in
// basic_bulk_insert.cpp to be created in the test database
//
// NOTE: if you edit this file please update the line numbers in
// basic_bulk_insert.rst

#include <libmcsapi/mcsapi.h>
#include <iostream>

int main(void)
{
    mcsapi::ColumnStoreDriver* driver = nullptr;
    mcsapi::ColumnStoreBulkInsert* bulk = nullptr;
    try {
        driver = new mcsapi::ColumnStoreDriver();
        bulk = driver->createBulkInsert("test", "tmp2", 0, 0);
	mcsapi::ColumnStoreDecimal aData;
	mcsapi::ColumnStoreDecimal bData;
	aData.set("100000000.999999999000000000");
	bData.set("23.42");
       	bulk->setColumn(0, aData);
       	bulk->setColumn(1, bData);
       	bulk->writeRow();
        bulk->commit();
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    delete bulk;
    delete driver;
}
