Trigger insert on parent table question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sean

    Trigger insert on parent table question

    Hey all, I'm new to triggers and I don't know if what I want is
    possible.


    I have a parent table, dbobjects say. And I have a persons table.

    bdobjects.id is a primary key
    persons.id is a primary key and references dbobjecs.id.

    Descriptively what I want is:

    Before insert on persons
    Insert a row in the dbobjects table *sys_guid() is default for this
    column*
    Iake the value of the new dbojects.id field and assign it to the
    persons.id field of the row about to be inserted
    Continue with persons insert

    Can this be done? Oracle 10g BTW.

    Thanks so much
  • DA Morgan

    #2
    Re: Trigger insert on parent table question

    Sean wrote:
    Hey all, I'm new to triggers and I don't know if what I want is
    possible.
    >
    >
    I have a parent table, dbobjects say. And I have a persons table.
    >
    bdobjects.id is a primary key
    persons.id is a primary key and references dbobjecs.id.
    >
    Descriptively what I want is:
    >
    Before insert on persons
    Insert a row in the dbobjects table *sys_guid() is default for this
    column*
    Iake the value of the new dbojects.id field and assign it to the
    persons.id field of the row about to be inserted
    Continue with persons insert
    >
    Can this be done? Oracle 10g BTW.
    >
    Thanks so much
    Anything can be done. But two questions:
    1. Why are you deciding how you want to do something rather than
    stating a business case?

    2. Why didn't you just try it?

    Personally I think you are creating great complexity where simplicity
    would suffice.
    --
    Daniel A. Morgan
    University of Washington
    damorgan@x.wash ington.edu
    (replace 'x' with 'u' to respond)

    Comment

    Working...