List:MySQL++« Previous MessageNext Message »
From:Jim Wallace Date:March 7 2009 2:33am
Subject:RE: how pass SQLTypeAdapters to create a SQLQueryParms(supplementary explanation)?
View as plain text  
Warren said using the SQLTypeAdapter is not the preferred way to do it.  Have you looked through the examples.  Warren has done a great job with them and I'm sure there's one that does something like what you're trying to do.

I'm not sure what you mean by using variables.  Why not something like this?

Query query = serverConn.query("INSERT INTO sync_status VALUES(%0q,%1,%2q)");
query.parse();

string s( "Alex" );
int x = 0;
string s( "sync" );

query.execute( s, x, t );

-----Original Message-----
From: Alex Luya [mailto:alex_luya@stripped] 
Sent: Friday, March 06, 2009 9:07 PM
To: MySQL++ Maillist
Subject: how pass SQLTypeAdapters to create a SQLQueryParms(supplementary explanation)?

In fact,I need to pass variables to template query(counts changed 
dynamically),so make a  test to try to run following code,but got an 
exception:Not enough parameters to fill the template.So can any guys 
point out the issues for me?Thank you.
------------------------
try {
               Query query = serverConn.query("INSERT INTO sync_status 
VALUES(%0q,%1,%2q)");
               query.parse();

               SQLQueryParms sqp;
               SQLTypeAdapter sta0("Alex Luya");
               sqp<<sta0;
               SQLTypeAdapter sta1(DateTime("2009-03-04 14:33:31"));
               sqp<<sta1;
               SQLTypeAdapter sta2("synchronizing");
               sqp<<sta2;
               SimpleResult res1 = query.execute(sqp);
           }
           catch (const mysqlpp::Exception& er) {
                cerr << "synchronize-Exception: " << er.what() << endl;
           }
------------------------
-- --------------------------------------------------------
-- Structure de la table `sync_status`

CREATE TABLE IF NOT EXISTS `sync_status` (
`sync_user` varchar(20) NOT NULL,
`start_time` datetime NOT NULL,
`status` varchar(13) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- 
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:    http://lists.mysql.com/plusplus?unsub=jwallace@stripped


Thread
how pass SQLTypeAdapters to create a SQLQueryParms(supplementaryexplanation)?Alex Luya7 Mar
  • RE: how pass SQLTypeAdapters to create a SQLQueryParms(supplementary explanation)?Jim Wallace7 Mar
  • Re: how pass SQLTypeAdapters to create a SQLQueryParms(supplementary explanation)?Warren Young7 Mar
Re: how pass SQLTypeAdapters to create a SQLQueryParms(supplementaryexplanation)?Alex Luya8 Mar