Reputation: 3651
I'm using oracle 11G with OJDBC6.jar adapter. when I try to run this very simple insert statement, it throws an invalid character exception.
ActiveRecord::JDBCError: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character
: insert into user_defaults values (8526547125,'H214Qa99547')
My gemfile is as follows:
gem 'activerecord', '4.0.4'
gem 'ActiveRecord-JDBC', '0.5'
gem 'activerecord-jdbc-adapter', '1.3.6'
This is on Oracle 11g with OJDBC6.jar
Upvotes: 0
Views: 768
Reputation: 6067
add this line statement_escape_processing: true
in the database configuration file, like this. This should sort the issue
development:
adapter: jdbc
driver: oracle.jdbc.OracleDriver
statement_escape_processing: true
Upvotes: 0
Reputation: 13377
I've been burned by out-of-range ASCII in the past. It would be best to rule that out, especially if you've tried everything else that you can think of.
Delete and retype the entire line or lines. Resist the temptation to paste the line after you delete it. If there's a non-printable ASCII character in there, it'll get rid of it.
Make sure that you do this for any line of code that interacts with the SQL statement, whether it be building the string in a variable or actually passing the argument to run the query.
Upvotes: 0
Reputation: 39464
Could this be to do with the inferred column order? Try specifying the columns to remove any ambiguity:
INSERT INTO user_defaults (user_id, home_office_id)
VALUES (8526547125, 'H214Qa99547')
Upvotes: 1
Reputation: 9904
Upvotes: 0