Thanks you very much for your reply, Julian, quite useful
However, in case of update, it seems that indicator does not work as well. I 
can not handle an exception thrown from such update query.
sql     << "UPDATE my_table  SET "      << "name =: first_name '"       << " 
WHERE UsrId = :user_id ", use(first_name,ind), use(user_id);For example when 
user_id does not exist, of course the row is not updated but I got no message 
using                   switch (ind)                    {                       
case i_ok:                                message here                          
break;                  case i_null:                                message 
here                                break;                  case i_truncated:   
                             message here                           break;      
            }Any idea how to catch such exception from an update query ???
RegardsVDung

--- On Sat, 2/19/11, Julian Taylor <[email protected]> wrote:

From: Julian Taylor <[email protected]>
Subject: Re: [SOCI-users] Remote database and exception handling
To: "General-purpose list for SOCI users." <[email protected]>
Date: Saturday, February 19, 2011, 2:45 AM

On Fri, 2011-02-18 at 07:42 -0800, Doan Viet Dung wrote:
> Hi all,
> 
> 
> I have two questions, thanks in advance for any suggestion
> 
> 
> The first one is does soci support to connect to a remote database
> (mysql) ? If yes then how can I do ?
> 
> 
> The second one is: given my below code, when the select query returns
> no result, the exception did not throw any thing and the program
> continues as normal. How can I catch such exception ? 
> 
> 

1. set the host and if required the port in the connection string.
e.g. host='some.host.de' port=3306 db=database user=bla password='...'
http://soci.sourceforge.net/doc/backends/mysql.html

2. session has the got_data method to check if the query returned a
result:
rootSession << "select rights from myTable where user_id =:id ",
into(rights, ind), use(user_id);
if (rootSession.got_data()) {
...
}
http://soci.sourceforge.net/doc/exchange.html

Best Regards,
Julian Taylor

-----Inline Attachment Follows-----

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
-----Inline Attachment Follows-----

_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users



      
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to