4 messages in com.mysql.lists.plusplusRe: query.preview() and update questions
FromSent OnAttachments
Kid Akira10 Jul 2003 06:50 
Sinisa Milivojevic11 Jul 2003 04:15 
Kid Akira14 Jul 2003 09:58 
Sinisa Milivojevic14 Jul 2003 14:48 
Subject:Re: query.preview() and update questions
From:Sinisa Milivojevic (sin@beotel.yu)
Date:07/11/2003 04:15:19 AM
List:com.mysql.lists.plusplus

On Thu, 10 Jul 2003 09:50:35 -0400 "Kid Akira" <kida@msn.com> wrote:

Hi,

I was hoping someone on this list could help me with the following questions that I have.

1. I've been looking over the tutorial and have noticed in some of the examples listed I do not get an output from a query.preview() command.

ex: This segment of code will output: Query:

What is the output from custom2.cc.

If it is empty too, then it is a bug.

What compiler are you using ???

I have tried creating a string variable and setting that equal to the results of the query.preview() but that results in an empty output also.

2. I have having problems updating my tables. I am trying to update a table that consists of 60+ fields. Using the example code of: Query query = con.query(); (std::ostream&)query << MY_QUERY; ResUse res = query.use(); Row row; strbuf << "delete from " << MY_TABLE << " where " << MY_FIELD << " in ("; // for UPDATE just replace the above DELETE FROM with UPDATE statement for(;row=res.fetch_row();i++) strbuf << row[0] << ","; if (!i) return 0; string output(strbuf.str()); output.erase(output.size()-1,1); output += ")"; query.exec((const string&)output); // cout << output << endl;

I'm not sure what the proper syntax should be if I were to update multiple fields. Would it just be: strbuf << "update << MY_TABLE << "set " << MY_FIELD1 << "=" << some_value << MYFIELD2 << "=" << another_value ?

I realize that I can bypass using the update command by modifying my sql_query0.hh file to be able to read in the appropriate amount of parameters but I didn't want to pass a 60 parameter function :)

Thank you for your time, If I explained anything poorly, or if more clarification is needed please let me know.

~ Andrew

No need to bypass anything.

updel.cc example is doing 100 % what you need.

For several columns to update, just do :

SET column1=.., column2=...

Regards,