SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.37k stars 472 forks source link

insert null value error #1040

Closed stan1334 closed 1 year ago

stan1334 commented 1 year ago

sqlite3 win10 64

//创建数据表sql

define CREATE_HE_DATA_TABLE_SQL ("create table HE_DATA ("\

"SOURCENODE varchar(256),"\

struct TestData{ std::string PARENTNODE; int another; XXX }

    static void to_base(const TestData& p, values& v, indicator& ind)
    {
      v.set("PARENTNODE", p.parentNode, p.parentNode.empty() ? i_null : i_ok);

}

when i insert struct a field is null,soci err info:: what:Null value not allowed for this type while executing "insert into

soci::transaction tr(*sql); T insertData; soci::statement st = (sql->prepare << strSql, SQL_USE(insertData));

for (auto& data : datas) { insertData = data; st.execute(true); errroIndex++; } tr.commit();

soci err info:: what:Null value not allowed for this type while executing " insert into HE_DATA (EVENTID,SOUR XXX PARENTNODE=NULL,

create field default can write null "SOURCENODE varchar(256),"\

or "SOURCENODE varchar(256) not null,"\ always have same err

Please help guide @vadz

stan1334 commented 1 year ago

Both get and set need to determine i_null