[odb-users] Output of native SQL statement in SQLite.
Boris Kolpackov
boris at codesynthesis.com
Mon Jan 9 09:21:52 EST 2017
Hi Rohith,
Tenneti, Rohith UTC CCS <Rohith.Tenneti at fs.utc.com> writes:
> I am trying to capture the output of SQL statement in SQLite
> "PRAGMA integrity_check;" using :
>
> session s;
> transaction t( db->begin() );
>
> numRows = db->execute("PRAGMA integrity_check");
>
> t.commit();
According to the SQLite documentation, "If the integrity_check pragma finds
problems, strings are returned (as multiple rows with a single column per
row) which describe the problems. If pragma integrity_check finds no errors,
a single row with the value 'ok' is returned."
So in a sense it behaves like SELECT which means you can use a view to
get the result:
#pragma db view query("PRAGMA integrity_check")
struct integrity_check
{
std::string problem;
};
for (const integrity_check& ic: db.query<integrity_check> ())
{
cerr << ic.problem << endl;
}
Boris
More information about the odb-users
mailing list