Friday, 15 April 2011

rserve - Using R variable in SQL Query -



rserve - Using R variable in SQL Query -

i using rserve , sql in java info database , plot results in , r plot. working fine need utilize variable in sql query.

in php know need close statement, add together variable , reopen statement.

however, when seek in rserve page hangs.

my code follows:

string uid = session.getattribute("sessionuid").tostring(); c.assign("uid", uid); c.eval("df <- data.frame(dbgetquery(con, paste('select uid, buildingcode, " + "date_format(accesstime, \"%d-%b-%y\") date test uid=\"'+uid+'\"')))");

without where uid=\"'+uid+'\" code works know problem, don't know solution?

note: have tried using , instead of + stated in this answer didn't seem work either.

solved it!

the problem where uid=\"'+uid+'\" instead of trying escape " \" added quotes when assigning session string.

instead of this:

string uid = session.getattribute("sessionuid").tostring();

i used this:

string uid = '"'+session.getattribute("sessionuid").tostring()+'"';

and works perfectly! although still puzzled why \" throwing error.

sql rserve

No comments:

Post a Comment