Open wlodi83 opened 11 years ago
Why RDBI doesn't support group_concat function?
Similar problem happens when database returns null value.
@wlodi83, can you provide a concise, complete, and correct code sample that reproduces your symptoms?
Can you also supply relevant versions for: rdbi, rdbi-driver-odbc, ruby-odbc, your system odbc library, and the backend database? Also, what is the backend database, MySQL or HSQLDB?
Hello,
I am using following gems:
gem list
* LOCAL GEMS *
bundler (1.3.5) dbd-odbc (0.2.5) dbi (0.4.5) deprecated (2.0.1) epoxy (0.3.1) methlab (0.1.0) rake (10.0.4) rdbi (0.9.1) rdbi-driver-odbc (0.1.2) ruby-odbc (0.99995, 0.99992) rubygems-bundler (1.1.1) rvm (1.11.3.7) typelib (0.1.0)
I am using unixODBC library on Ubuntu 12.04. Database is EXASOL.
This is example of code:
require 'rdbi-driver-odbc' dbh = RDBI.connect :ODBC, :db => "EXA", :user => "test", :password => "test" rs = dbh.execute "select nvl(tar.aff_status, 0), tar.s_status, count(*), group_concat(toc.country_code) from ids.track_conversions as tar join ids.track_click as toc on tar.subid = toc.subid where toc.aff_id = '52' and toc.CREATED_AT >= curdate()-3 group by 1,2" print rs.fetch(:all) dbh.disconnect
it returns an error:
/home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in fetch': negative string size (or size too big) (ArgumentError) from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in
initialize'
from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:in new' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:in
new_execution'
from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/statement.rb:163:in execute' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/database.rb:189:in
execute'
from rdbi.rb:5:in `
If I will remove the group_concat function everything is OK.
Regarding null values:
I am getting following error if I will remove "nvl" function from the code:
/home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in fetch': failed to allocate memory (NoMemoryError) from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in
initialize'
from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:in new' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:in
new_execution'
from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/statement.rb:163:in execute' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/database.rb:189:in
execute'
from rdbi.rb:5:in `
require 'rdbi-driver-odbc' dbh = RDBI.connect :ODBC, :db => "EXA", :user => "test", :password => "test" rs = dbh.execute "select tar.aff_status, tar.s_status, count(*) from ids.track_conversions as tar join ids.track_click as toc on tar.subid = toc.subid where toc.aff_id = '52' and toc.CREATED_AT >= curdate()-3 group by 1,2" print rs.fetch(:all) dbh.disconnect
Hi pilcrow,
do you know where could be the problem?
I'm also having this problem. Using 2.0.0-p247.
Hi, when I use RDBI and query with group_concat function I am getting following error:
.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in `fetch': negative string size (or size too big) (ArgumentError)