Hi,

Is there a way of accurately bulk inserting into a decimal field in SQL
server? I'm trying to insert into a table called nets, which has 2 column,
an integer column (id) and a decimal(23,6) column (net). This is the code
I'm using:-

 try
    {
        session sql("odbc", "DSN=socitest;Uid=sa;Pwd=XXXXX;");

        vector<int> ids;
        vector<string> nets;

        for (int i = 0; i != 1000; ++i)
        {
            ids.push_back(i);
            nets.push_back("1234.123456");
        }

        sql << "insert into nets(id, net) values(:id, :net)",
            use(ids), use(nets);


    }
     catch (soci::odbc_soci_error const& e)
    {
        cerr << "ODBC Error Code: " << e.odbc_error_code() << endl
             << "Native Error Code: " << e.native_error_code() << endl
             << "SOCI Message: " << e.what() << std::endl
             << "ODBC Message: " << e.odbc_error_message() << endl;
    }
    catch (exception const &e)
    {
        cerr << "Error: " << e.what() << '\n';
    }

And I get:-

ODBC Error Code: 01000
Native Error Code: 0
SOCI Message: Statement Execute
ODBC Message: [SOCI]: No error.

If I change the string vector to doubles, it works fine, but will lose
precision (and it works fine via the MySQL backend).

Thanks

Andy
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
soci-users mailing list
soci-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to