Re: [Sqlrelay-discussion] sqlrelay 0.45 and mysql 5.1.62 C++ -- bind problem
Brought to you by:
mused
From: David M. <dav...@fi...> - 2012-07-27 17:53:07
|
I believe that MySQL uses ?'s as placeholders for bind variables. So, you would need to write your queries like: cur->prepareQuery("select * from testtable2 where id=?"); cur->inputBind("1",1); cur->executeQuery(); Note the use of "1" rather than "id1". When using ?'s, you must use 1,2,3, etc. for the variable name. Alternatively, there is a parameter in the sqlrelay.conf file called "translatebindvariables" which defaults to no, but if you set translatebindvariables="yes" then it will basically allow you to use any style of bind variables you like and dynamically rewrite the queries on the server-side as appropriate. There is a performance penalty for this, but it's not very large. Let me know if this helps or not. David Muse dav...@fi... On 07/27/2012 01:22 AM, Vishal Shah (GDC) wrote: > hello, > > I am new to sqlrelay and have the following query on using the bind > variables of mysql using sqlrelay. the version of distributions i am > using is mentioned in the subject > > I am using the C++ api of sqlrelay. > > I prepare a mysql statement as below (please not that I use `@' > instead of `:' mentioned in the tutorial, as `:' was giving MySQL > errors) > > cur->prepareQuery ("select * from testtable2 where id=@id1"); > cur->inputBind("id1",1); > cur->executeQuery (); > > While the above three statements don't generate any errors, I don't > get the results. > > If I did > > > cur->prepareQuery ("select * from testtable2 where id=:id1"); > cur->inputBind("id1",1); > cur->executeQuery (); > > MySQL generated errors as in Wrong Syntax. > > Anything that I would have missed? sqlrconnection, sqlrcursor are > properly initialized and if I do: > > cur->prepareQuery ("select * from testtable2 where id=1"); > cur->executeQuery (); > > i do get the results. > > SQLRelay Experts, please guide. > > Regards, > > BIC > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Sqlrelay-discussion mailing list > Sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion > |