Created
January 12, 2012 15:08
-
-
Save tobytripp/1601028 to your computer and use it in GitHub Desktop.
Ruby OCI, you make me sad…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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