After upgrading from 1.2.4 to 1.3.0 I'm now getting a ORA-22816 error
when trying to insert a record into a view with an INSTEAD OF trigger
defined. eg:
Repairer Create (0.0ms) OCIError: ORA-22816: unsupported feature
with RETURNING clause: INSERT INTO "REPAIRER" ("REPA_MAIL_LIST_IND",
"REPA_PICTURE_FILE_NAME", "REPA_POSTAL_ADDR", "REPA_EFF_DTE",
"REPA_REF", "REPA_ACTIVE_IND", "REPA_DESC_OF_SERVICES", "REPA_NAME")
VALUES(NULL, NULL, NULL, NULL, NULL, NULL, 'Car Fixin', 'John')
RETURNING "REPA_ID" INTO :insert_id
vendor/gems/activerecord-oracle_enhanced-adapter-1.3.0/lib/
active_record/connection_adapters/oracle_enhanced_adapter.rb:1726:in
`log'
vendor/gems/activerecord-oracle_enhanced-adapter-1.3.0/lib/
active_record/connection_adapters/oracle_enhanced_adapter.rb:605:in
`execute'
vendor/gems/activerecord-oracle_enhanced-adapter-1.3.0/lib/
active_record/connection_adapters/oracle_enhanced_adapter.rb:629:in
`insert_sql'
This seems to be expected behavior as you can't use RETURNING INTO
when inserting in a view. (See
http://www.orafaq.com/forum/t/55859/0/)
The problem seems to lie in the insert_sql function in
oracle_enhanced_adapter, but only when the primary key hasn't already
been set - I've worked around this (temporarily at least) by manually
fetching the primary key from the sequence in a before_create callback
on the model.
Is this a bug, or just a limitation of working with views that I'm
going to have to put up with?
Cheers
Dave Smylie