dbTalk Databases Forums  

Problem with DELETE

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Problem with DELETE in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Muller Gael
 
Posts: n/a

Default Problem with DELETE - 08-13-2006 , 04:32 PM






Hello everyone.

I'm just starting with mysql++ and I have a problem with a DELETE query:

-------------------------------------------------------------------------------------------------------------------------
mysqlpp::Connection db("CycomT", "localhost", "root", "");

mysqlpp::Query query = db.query();
query << "SELECT * FROM actions";
mysqlpp::Result result = query.store();
if (result) {
if (result.num_rows() != 0) {
try {
mysqlpp::Row row;
while (row = result.fetch_row()) {
std::cout << row["type"];
}
}
catch (mysqlpp::EndOfResults& er) {
//on ne fait rien
}
query.reset();
query << "DELETE FROM actions";
query.execute();
}
}


-----------------------------------------------------------------------------------------------------------------------------

The DELETE query seems to be executed before the SELECT query. Indeed my
table is'nt empty before, but my program doesn't print anything. Then,
my table is empty as expected. I don't understand why. Without the
DELETE query, my program prints the content correctly.

Sorry for my English,
Thanks for help

--
Muller Gael

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: Problem with DELETE - 08-14-2006 , 08:28 AM






Muller Gael wrote:
Quote:
std::cout << row["type"];
Add " << endl" or " << flush" to the end of this statement. IOStreams
will buffer output otherwise, making it difficult to determine which
order things actually happen in.

Quote:
catch (mysqlpp::EndOfResults& er) {
//on ne fait rien
}
Add a cout statement in here (again, with a flush or newline).

Quote:
query.reset();
query << "DELETE FROM actions";
query.execute();
Add one after this, too.

Do all that and try it again. It may be that things are not happening
in the order you think they are.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.