dbTalk Databases Forums  

Newbie query use help.

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


Discuss Newbie query use help. in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Benjamin Liu
 
Posts: n/a

Default Newbie query use help. - 07-20-2005 , 06:12 PM






Hi folks,

I'm a humble non-programmer who just wants to read a float table value into
a float variable.
----------------------------------------------------------------------------
-------------
Query query = con.query();
query << "select kwh from basic120 order by time desc limit"; // Last value
this column.
mysqlpp::ResUse res = query.use();
???
float kwh = ???
----------------------------------------------------------------------------
-------------
I've tried using the method Fields but can't get it to compile.

Thanks,

Benjamin Liu



--
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   
Chris Frey
 
Posts: n/a

Default Re: Newbie query use help. - 07-21-2005 , 05:16 PM






On Wed, Jul 20, 2005 at 04:10:46PM -0700, Benjamin Liu wrote:
Quote:
Hi folks,

I'm a humble non-programmer who just wants to read a float table value into
a float variable.
----------------------------------------------------------------------------
-------------
Query query = con.query();
query << "select kwh from basic120 order by time desc limit"; // Last value
this column.
mysqlpp::ResUse res = query.use();
???
float kwh = ???
----------------------------------------------------------------------------
-------------
I've tried using the method Fields but can't get it to compile.
Check out the usequery.cpp example, or some of the other files in the
examples/ subdirectory.

Here's a snippet:

// Execute the query, but don't save results in memory
mysqlpp::ResUse res = query.use();
if (!res) {
std::cerr << "Result set is empty!" << std::endl;
return 1;
}

// Iterate through result set, printing each row.
mysqlpp::Row r;
while (r = res.fetch_row()) {
print_stock_row(r);
}

i.e. you need to use a Row object, and fetch each row, then access the
data from that row.

More docs are here: http://tangentsoft.net/mysql++/doc/

- Chris


--
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.