Comments (2)
It looks like I can't compare the if (row.timestamp == std::tm())
, so I change the code like below:
bool IsTmEmpty(const std::tm& time) {
return (time.tm_year == 0 &&
time.tm_mon == 0 &&
time.tm_mday == 0 &&
time.tm_hour == 0 &&
time.tm_min == 0 &&
time.tm_sec == 0);
}
And later, I use such code:
static void to_base(const MyClass& row, values& v, indicator& ind)
{
v.set("id", row.id);
// check to see whether the row.timestamp is an empty null "std::tm", if true, set the field value as NULL
if ( IsTmEmpty(row.timestamp) )
{
v.set("timestamp", soci::i_null);
}
else
{
v.set("timestamp", row.timestamp);
}
ind = i_ok;
}
But sadly, the above code still can't be built. The issue happens here: v.set("timestamp", soci::i_null);
, I'm currently don't know how to use the null indicator.
Thanks.
from soci.
OK, I think I found the solution, it is inside the document:
See here:
So, the final code which works is like below:
static void to_base(const MyClass& row, values& v, indicator& ind)
{
v.set("id", row.id);
// check to see whether the row.timestamp is an empty null "std::tm", if true, set the field value as NULL
v.set("timestamp", row.timestamp, IsTmEmpty(row.timestamp) ? i_null : i_ok);
ind = i_ok;
}
from soci.
Related Issues (20)
- failed to connect to mysql database after I upgrade the mariadbclient library inside the msys2 HOT 2
- MSVC: number of sections exceeded object file format limit
- Issue with Boost 1.84 HOT 6
- Incorrect query result with `use` and `into` into vector, at least for sqlite3. HOT 1
- Incorrect query result with `use` and `into` into vector, at least for sqlite3. HOT 2
- SOCI with MySQL on Linux (Ubuntu) - impossible to link static HOT 12
- Dates before year 1900 stored in Oracle as one hundred years earlier. HOT 1
- Win10, sqlite3 , MultiThread , Can not use into and use . HOT 2
- Getting Invalid Cursor State on mssql - complex queries - Urgent help needed HOT 3
- BLOB does not work in Oracle HOT 11
- Cant use sqlstate(). Undefined reference HOT 2
- Using `row::move_as` while iterating `rowset` yields segmentation fault HOT 3
- Memory Leak when trying to connect to Microsoft SQL Server HOT 3
- How to create database using soci in mysql? HOT 1
- MariaDB? HOT 1
- Query not working through freeTDS works in Microsoft ODBC Driver HOT 4
- fatal error: 'mysql.h' file not found HOT 21
- File "private/soci-trivial-blob-backend.h" missing HOT 5
- Metadata and schemas other than public HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soci.