开发者

Triggers: How can I make this integrity restriction in Oracle?

I want to make it so each time a register of type Pilot or type Flight_Attendant is added, a register of type Crew is added. I'm working on Oracle's SQL Developer on top of 10开发者_开发知识库g, should I use a trigger?


That would be one way of doing what you want. Another it so write a stored procedure to you need to call. The procedure would perform the registration of the Pilot or Flight_attendant and type Crew.

For example, I would have a procedure REGISTER_CREW which takes a crew_type parameter (along with other details) and have that correctly register the Crew type, and the pilot and flight attendant. That way, if there are other rules they can all be added in the same place.


Personally I prefer triggers, because it does not require changes to app code that may be inserting to the table. Once the trigger is on there, a BEFORE INSERT, then the new rows in CREW type appears magically with no change to code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜