I've a very simple ruby file as described as provided below.
When I run the file the indication I get back from the .save method is
that
the notified attribute change has been saved and yet when I retrieve the
row again straight away after the notified value hasn’t changed and when
I
look at the db sure enough it hasn’t changed. I’m running
Here’s the DDL for the table, sequence and trigger
–Table
create table ALERTS (
alert_id number PRIMARY KEY ,
parent_id number,
creation date NOT NULL,
message varchar(100) NOT NULL,
throwable varchar(3000),
severity_id number CHECK ( severity_id IN (10000, 20000, 30000,
40000, 50000)) NOT NULL,
severity_status varchar(20) CHECK (severity_status IN (‘DEBUG’,
‘INFO’, ‘WARN’, ‘ERROR’, ‘FATAL’)) NOT NULL,
notified CHAR(1) DEFAULT (‘N’) CHECK (notified IN ( ‘Y’, ‘N’ )) ,
trace_user varchar(20),
trace_session varchar(50),
CONSTRAINT fk_alert
FOREIGN KEY (parent_id)
REFERENCES alerts(alert_id)
);
–Sequence
create sequence ALERT_SEQ
start with 1
increment by 1
nomaxvalue;
– Trigger
CREATE OR REPLACE TRIGGER STAGING_OWNER.ALERT_TRIGGER
BEFORE INSERT ON STAGING_OWNER.ALERTS
FOR EACH ROW
begin
select ALERT_SEQ.nextval into :new.alert_id from dual;
end;
I’ve since successfully performed the jruby ActiveRecord-JDBC found
here.
using the exact same connection specifications as in my example and it
works
fine. Tables are on the same database and everything so I think I can
rule out
that it’s an oracle problem. Is that presumptuous?
I can perform updates to my alerts table by getting hte connection and
calling
the update method with some SQL but this isn’t the way I was hoping to
develop it.
Had to resort to querying the V$SQL statements at the oracle
DB.
Does anyone know how to output the SQL generated by ActiveRecord-JDBC?
Would’ve made life a little easier.
Anyways it turns out the problem was in the line in my Alert model,
set_primary_key “ALERT_ID”
ALERT_ID is indeed the primary key of the table, however,
the attribute name in the Alert object is lowercase, alert_id.
Because of that update sql was being appended with
‘WHERE ALERT_ID is NULL’ sure enough none of the records
have and alert_id of null as its the primary key.