更新2个表中的2列并连接多个表

时间:2012-12-07 19:45:05

标签: sql oracle10g

我无法更新多个表中的多个行并加入多个列,我必须更新名为policy的表中的到期日期,并且还要将名为rating_record的表中的费率给予目前拥有的所有员工10%的折扣强制执行的政策。我可以给出满足所有标准的10%折扣,但无法弄清楚如何更新有效期 - 请帮忙!

我到目前为止的代码是我必须使用第二次更新功能使所有员工到期日为31日。这需要使用SQL开发人员在Oracle 10g中完成

    update rating_record
     set rate=(rate-(100/10)) where exists
    (select rating_record.rate from
    rating_record, coverage, policy, insured_by, client, person, staff
    where
   staff.pid = person.pid and
    client.pid = person.pid and
     client.cid = insured_by.cid and
    policy.pno = insured_by.pno and
     policy.pno = coverage.pno and 
    coverage.coid = rating_record.coid and
     policy.status = 'E');

1 个答案:

答案 0 :(得分:0)

您只能在UPDATE语句中更新一个基表的值。您应该创建一个过程,并在事务中包装两个更新语句(每个表一个要更新)。

相关问题