Oracle triggers - problem with mutating tables

前端 未结 8 1839
情书的邮戳
情书的邮戳 2020-12-06 19:31

My tables:

TableA (id number, state number)
TableB (id number, tableAId number, state number)
TableC (id number, tableBId number, state number)
8条回答
  •  無奈伤痛
    2020-12-06 19:43

    Can you refactor the solution to include views to perform the calculation ?

    CREATE VIEW a_view AS
    SELECT a.Id, min(b.State) State FROM tableA,tableB
    WHERE a.Id=b.tableAId
    GROUP BY a.Id;
    

    I agree that stored procs (as suggested here in other posts) are also a good candidate - but note that the view will automatically be kept up-to-date, whereas I believe you would have to schedule running stored-procs to keep the data 'in-sync': which may be fine - it depends on your requirements.

    I guess another option is to create some functions to do the calculation, but personally I would opt for the view-approach (all things being equal).

提交回复
热议问题