dbTalk Databases Forums  

sql_create in header

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


Discuss sql_create in header in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
don thompson
 
Posts: n/a

Default sql_create in header - 04-07-2005 , 04:26 PM






I have a class csdata which uses sql_create_20(tshares,... , and would
like to define 'tshares row' as a member of this class. Class ctran
contains members of class csdata, so it includes its header file
(csdata.h). Below are the errors.
Is it possible to include this into a header file? How? My header files
have the standard :
#ifndef __csdata_hh__
#define __csdata_hh__
I'm sure this is more of a c++ question, but using these SSQLS
structures is central to effectively using mysql++, and I'm stuck.
thanks, Don

gcc compile errors:
In file included from ctran.h:6,
from cldata.h:7,
from cldata.cpp:3:
<...sql_create_20... is on line 13 of csdata.h:>
csdata.h:13: error: syntax error before `*' token
csdata.h:13: error: type specifier omitted for parameter `cchar'
csdata.h:13: error: parse error before `*' token
csdata.h:13: error: missing ';' before right brace
.... lots of errors like above...
csdata.h:13: error: `tshares' is not a template type
csdata.h:13: error: definition of `struct tshares' inside template parameter
list


--
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: sql_create in header - 04-07-2005 , 05:10 PM






don thompson wrote:
Quote:
like to define 'tshares row' as a member of this class.
If I understand you correctly, you are trying to store instances of a
C++ class into columns of the MySQL database. This will not work; MySQL
is not an object-oriented database. You can only use primitive types
(int, float, char*...), or types like std::string which can be readily
converted to primitives.

Also, please don't reply to an existing thread in order to post to the
list. It messes up mail readers that can do threaded reading. Make a
fresh post instead.

--
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
  #3  
Old   
don thompson
 
Posts: n/a

Default Re: sql_create in header - 04-08-2005 , 07:58 AM



Hi, Below describes what I'm trying to do. I'm not trying to write an
object to the database, but
I simply want the SSQLS tshares definition (tshares shr) moved to the
header file of the class,
and therefore need to move the tshares definition. I'm trying to
develop some demonstration classes
which utilize various features of mysql++.
Thanks, Don

The SSQLS usage as shown is taken directly from examples/custom3

..... SSQLS declared in class.cp
sql_create_20(tshares.... <===SSQLS
..... in member function...
res = query.store(acct, sfx);
if (res.empty()) {
throw Acct_error(acct, sfx);
}
//because only one row can be returned
//shr = res[0]; <====would like tshares shr delcared as
class member,
tshares shr = res[0]; // using local <===rather than this local def.

..... and later to perform update ... <===this update would be in
another member function,
tshares shr2 = shr; <===thus the need for shr to be a class
member as well
// Test simple update
shr.balance += tranamt; <==== simple, rather than row numeric ref
or name lookup
query.update(shr2, shr);


Warren Young wrote:

Quote:
don thompson wrote:

like to define 'tshares row' as a member of this class.


If I understand you correctly, you are trying to store instances of a
C++ class into columns of the MySQL database. This will not work;
MySQL is not an object-oriented database. You can only use primitive
types (int, float, char*...), or types like std::string which can be
readily converted to primitives.

Also, please don't reply to an existing thread in order to post to the
list. It messes up mail readers that can do threaded reading. Make a
fresh post instead.


--
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
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: sql_create in header - 04-08-2005 , 10:01 PM



don thompson wrote:
Quote:
csdata.h:13: error: type specifier omitted for parameter `cchar'
This is defined in defs.h, which is included by mysql++.h. You should
#include <mysql++.h> before custom.h.

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