如題:org_info 表內容如下:
ID NAME TEL ADDR OP_TYPE OCCUR_DATE
1001 aaa 888888 ppppppp 2014-07-23
1001 aaa 999999 ppppppp 2011-03-19
1002 bbb 666666 yyyyyyy 2014-09-15
1002 ipow 221 fghfghfh 2009-07-08
1002 ipow 221 iyyiwqwe 2006-02-24
1002 bbb 666666 yyyyyyy 2001-05-12
update (select row_number() over(partition by id order by occur_date ASC) RN,
oi.* from org_info oi) aa
set aa.op_type = 1 where aa.RN = 1
數據庫報錯:
ORA-01732: 此視圖的數據操縱操作非法
請問這為什麼錯?如果不能這樣寫,那麼用什麼方式還能實現此功能呢?謝謝~~~~
(希望實現按照ID分組,取出日期最小的那條記錄,將他字段OP_TYPE更新為1,求指導啊~~~)
update org_info set op_type = 1 where rowid in (
select rid
from (select rowid rid,
row_number() over(partition by id order by occur_date ASC) RN
from org_info oi)
where rn = 1
)