On 12/27/06 3:22 PM, Kevin McGrath wrote:
> Just wondering if there is a time line for some of these Oracle changes to
> be implemented?  The sequence addition would be very nice to have.  I have a
> kludge right now where I override the save function.

This is pretty much working in SVN.  No docs yet, but here's the short
version...

To get serial columns to work in Oracle, make your database column like
this:

    id INT NOT NULL PRIMARY KEY

(It doesn't have to be named "id".  Any name will do.  Also, probably any
integer-ish data type will work.)

Then create a sequence named like this:

    <table>_<column>_seq

For example, if the table is named "t1" and the desired serial column is
named "id", then create a sequence named "t1_id_seq"

    CREATE SEQUENCE rose_db_object_test_id_seq;

Now create a trigger on insert for the table that sets the primary key
column to the next value in the sequence:

    CREATE OR REPLACE TRIGGER t1_insert
    BEFORE INSERT ON t1 FOR EACH ROW
    BEGIN
      SELECT t1_id_seq.nextval INTO :new.id FROM dual;
    END;

Finally, set up the RDBO column metadata as usual for a serial column:

    columns =>
    [
      id => { type => 'serial', primary_key => 1, not_null => 1 },
      ...
    ]

You can override the auto-selected sequence name like this:

    columns =>
    [
      id => { type => 'serial', primary_key => 1, not_null => 1,
              sequence => 'some_other_seq' },
      ...
    ]

Sync from SVN and give it a whirl.  You'll need both the new Rose::DB and
Rose::DB::Object for it to work.  Docs to come, then (assuming no
outstanding bugs) release by the end of January.

-John



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to