List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:July 13 2011 8:37pm
Subject:Re: update fails... any suggestions?
View as plain text  
On 7/13/2011 2:04 PM, Jay Sprenkle wrote:
>
>           mysqlpp::Query query = conn.query( "UPDATE customer SET
> AccountName=%2q, Active=%3, Password=%1 WHERE CustomerId=%0" );
>           query.parse();
>           mysqlpp::SQLQueryParms parms;
 >           ....noise noise noise...

Why are you bothering with direct use of SQLQueryParms?  This does the 
same thing, with less code:

     mysqlpp::SimpleResult res = query.execute(
             mysqlpp::sql_int(CustomerId),
             mysqlpp::sql_blob(data, sizeof(data)),
             ...etc...);

> If I turn off exceptions for the connection it fails silently (the
> result.info() method returns nothing).

That just gets you "additional information".  To check for errors, test 
res in bool context instead:

     if (res) {
         // query was successful
     }
     else {
         // FAIL
     }

> if I turn exceptions on it seg faults here when trying to convert to a
> string:

You need to quote and escape BLOBs.  Your binary password is being 
inserted into the query string raw, as-is.

Consider using SSQLSes instead of template queries.  It handles quoting 
and escaping for you automatically.
Thread
update fails... any suggestions?Jay Sprenkle13 Jul
  • Re: update fails... any suggestions?Warren Young13 Jul
    • Re: update fails... any suggestions?Jay Sprenkle13 Jul
      • Re: update fails... any suggestions?Warren Young13 Jul
        • Re: update fails... any suggestions?Warren Young13 Jul
        • Re: update fails... any suggestions?Jay Sprenkle13 Jul
          • Re: update fails... any suggestions?Kemet14 Jul
            • Re: update fails... any suggestions?Warren Young14 Jul
              • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                  • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                    • Re: update fails... any suggestions?Jay Sprenkle14 Jul
                      • Re: update fails... any suggestions?Warren Young15 Jul
                        • Re: update fails... any suggestions?Jay Sprenkle15 Jul