On 07/03/11 14:03, Doan Viet Dung wrote: > Thanks alot Julian, > > Your solution works fine but it can not return the exception cause in > case the update request failed. For example, when someone try to update > a primary key field, how can we catch this exception (table, field name, > mySQL error message ...). I hoped the soci_mysql_exception could do this > but it did not :( > > Regards > VDung > >
the table and field should still be available from your statement the
error number can be retrieved from the err_num_ member and the error
string from the what() member.
sql << "INSERT INTO test (id, val) VALUES (5, 5)";
sql << "INSERT INTO test (id, val) VALUES (4, 6)";
try {
sql << "UPDATE test SET id=5 WHERE val=6";
}
catch (mysql_soci_error & e) {
cout << e.err_num_ << " " << e.what() << endl;
}
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________ Soci-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/soci-users
