Hi,

Using SOCI as the interface to an Sqlite3 database and a Postgres
database, I stumbled upon a "problem". I was using

try {
  dbSession << "UPDATE categories SET name=:NAME,
description=:DESCRIPTION WHERE id=:ID", soci::use(updatedCategory);
}
catch (soci::soci_error& ex) {
  // log error
}

When I try this statement with a value for :NAME that is already in
the table (UNIQUE column), I thought that until recently I got an
exception which could then be acted upon. However at the moment it
looks like the program just crashes on the dbSession << ... line.
If I however use

try{
soci::statement stUpdateCategory = (dbSession.prepare <<
        "UPDATE categories SET name=:NAME, description=:DESCRIPTION
WHERE id=:ID", soci::use(updatedCategory));

stUpdateCategory.execute(true);
}
catch (soci::soci_error& ex) {
  // log error
}

it seems to work correctly. My question now is, what is the correct
way to execute these statements that no really return data (INSERT,
DELETE etc)? When can I use the shorthand (once) notation?

Kind regards,
Christian Mol

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
soci-users mailing list
soci-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to