Skip to content

Instantly share code, notes, and snippets.

@tobytripp
Created January 12, 2012 15:08
Show Gist options
  • Save tobytripp/1601028 to your computer and use it in GitHub Desktop.
Save tobytripp/1601028 to your computer and use it in GitHub Desktop.
Ruby OCI, you make me sad…
#!/usr/bin/env ruby
ENV['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
require 'oci8'
def exec( connection, sql )
puts "exec: #{sql}"
connection.exec( sql ) { |r| puts r.join(', ') }
end
def main
connection = OCI8.new "dev", "password", "orcl"
exec connection, %q"select unistr('\200b') from dual" # This is okay
# The next two will never return. WTF why?
exec connection, %Q{UPDATE users SET last_name = '\u200b' WHERE (last_name IS NULL)}
exec connection, %q{UPDATE users SET last_name = UNISTR('\200b') WHERE (last_name IS NULL)}
connection.commit
ensure
connection.logoff
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment