ActiveRecord HABTM in Legacy DB not inserting properly

I’m doing some ORM to a legacy Oracle DB using ActiveRecord, not using
Rails, but since ActiveRecord is part of Rails, I figured this would be
the place for it.

When I create the habtm relationship, I can access the data just fine,
but when I use the << operator to add a record, I get the following
error:

The relationship in question has the following schema:

T_TRACK_DELIVERY_METHOD
Name Type


ID NUMBER(9)
DELIVERY_CODE VARCHAR2(30)
DISPLAY_NAME VARCHAR2(75)
DISPLAY_DEFAULT NUMBER(1)
[snip]

T_PROJECTS
Name Type


ID NUMBER(9)
NAME VARCHAR2(50)
ABBREVIATION VARCHAR2(10)
[snip]

T_TRACK_DELIVERY_METH_PRJ_X
Name Type


DELMETH_ID NUMBER(9)
PRJ_ID NUMBER(9)

here are my models:

--------------begin--------------

class Project < ActiveRecord::Base
has_and_belongs_to_many(
:deliverymethods,
:class_name => “DeliveryMethod”,
:association_foreign_key=>“DELMETH_ID”,
:foreign_key=>“PRJ_ID”,
:join_table=>“T_TRACK_DELIVERY_METH_PRJ_X”
)
set_table_name “T_PROJECTS”
set_sequence_name “S_PROJECTS”

end

class DeliveryMethod < ActiveRecord::Base
has_and_belongs_to_many(
:projects,
:association_foreign_key=>“PRJ_ID”,
:foreign_key=>“DELMETH_ID”,
:join_table=>“T_TRACK_DELIVERY_METH_PRJ_X”
)
set_table_name “T_TRACK_DELIVERY_METHOD”
set_sequence_name “S_TRACK_DELIVERY_METHOD”
end

-------------- end --------------

The following code:

--------------begin--------------

delmeth = DeliveryMethod.find(10)
prj = Project.find(1000)

prj.deliverymethods << delmeth
-------------- end --------------

Gives me this error:

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
log': OCIError: ORA-00928: missing SELECT keyword: INSERT INTO T_TRACK_DELIVERY_METH_PRJ_X () VALUES () (ActiveRecord::StatementInvalid) from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/oracle_adapter.rb:271:inexecute’

[snip]

Obviously for some reason ActiveRecord is not putting the column names
or values into the insert, but I’m having a heck of a time figuring out
why. Any info would be greatly apreciated.

I figured out what the problem is, the column names are case sensitive.
Oracle stores them as uppercase, but ActiveRecord lowers them and makes
them case sensitive.

Sorry, the error is at the bottom there, after the schema and code.

Sam wrote:

but when I use the << operator to add a record, I get the following
error:

The relationship in question has the following schema:

T_TRACK_DELIVERY_METHOD
Name Type


ID NUMBER(9)
[snip]

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
log': OCIError: ORA-00928: missing SELECT keyword: INSERT INTO T_TRACK_DELIVERY_METH_PRJ_X () VALUES () (ActiveRecord::StatementInvalid) from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/oracle_adapter.rb:271:inexecute’