From: Rob Biedenharn Date: 2008-10-17T02:08:38+09:00 Subject: Re: Ruby with Oracle forward slash error On Oct 16, 2008, at 12:59 PM, Sam Sang wrote: > Ok -- see what you mean, and doing that does make it a lot better! > Just > one last question in this regard.. > > Executing chunks works fine -- an issue is that if I have a few extra > empty lines (\n's) at the end of the file it will also try to execute > them and end up getting an > > -- execute(nil) > rake aborted! > OCIError: ORA-24373: invalid length specified for statement: > > > This is what I am currently using: > > string.each('/') {|s| execute(s.gsub! %r{^/}, '')} Don't use gsub! in this case. You just want gsub (read about what gsub! returns if it makes no change in string). -Rob > > My two thoughts are: > > 1) in between put in a if statement that checks for nils and only > execute if not nil. something like > string.each('/') {|s| if s != nil execute(s.gsub! %r{^/}, '')} > > > 2) do something like (string.gsub! %r{^/}, '').gsub! %r{^nil}, '') > > > I know that both of these syntax's are definitely incorrect but I > couldn't find material with which I could rectify it. > > Could you point me towards how to do an if statement inside the each > function in ruby? Or do another search-replace for nil's? > > Thanks! > > >> >> Instead of submitting the whole file as a single statement (string) >> to >> the database, parse (or split) it into chunks (using "^/" as >> delimiter) >> and submit those chunks one by one. >> >> Kind regards >> >> robert > > -- > Posted via http://www.ruby-forum.com/. > Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com