Search code examples
mysqlrlimitgroup-concatrodbc

RODBC changing limit for group_concat


I am using RODBC to connect R to a MySQL database. I have to use a group_concat in the select of my SQL query and I would like to change the default size limitation of the group_concat function.

test = sqlQuery(connect, "SET SESSION group_concat_max_len = 1000000; select group_concat(name) from country")

But I get the following error message:

[RODBC] ERROR: Could not SQLExecDirect 'SET SESSION group_concat_max_len = 1000000; select group_concat(name) from country'

Solution

  • You're trying to put two SQL queries into one call to RODBC's sqlQuery() method. You Can't Do That (tm). Call sqlQuery() for the SET query and again for the SELECT query.