1

所以基本上在我的数据库中,我有一个存储作业应用程序的表。这些应用程序具有用户将能够从下拉菜单更改为例如被邀请参加面试或申请成功的状态。我还有一个表需要存储每个应用程序的状态何时更改以及更改为什么。我想要这样做的方式是,我在 Oracle Application Express 上有一个显示某人应用程序的表单。然后,他们可以单击编辑按钮来更改其状态。当按下提交按钮时,我希望它更新应用程序表中的状态,但还要在历史表中创建一个新条目,其中包含状态更改为的值以及更改日期。我会为此使用触发器,还是在 Oracle Application Express 上有另一种方法。

4

1 回答 1

1

You can do either. Which is appropriate depends on your situation.

  1. If the history table is merely a journal table that records all changes to the application table, I'd be comfortable with a simple trigger on the application table that inserts into the history table. However, you need to check that triggers are allowed in your environment (some DBAs don't like them). The downside is that triggers can be disabled - which would mean your history table would not be updated, and your application won't realise it's not working - users will get no errors. The advantage is that the history table will be maintained regardless of which application is updating the application table - whether Apex or some other client.

  2. You can have one or more PL/SQL processes that run when the page is submitted, and you can put arbitrary PL/SQL in them - e.g. an update of the application status, followed by an insert into the history table. The advantage of this is that the code will either run successfully, or fail with an error, so you know the history will be in-sync with the application table. The disadvantage of this is that the logic is coded in your front-end code, as it were; if your company decides to write another interface that updates the application table, the history might not be inserted (or not inserted in the same way).

  3. Write a wrapper procedure for the application status change, which does both of these actions; and call this procedure from your Apex PL/SQL process. This way the procedure can be re-used by other systems (if they're ever needed).

于 2012-12-06T05:55:41.027 回答