Optimizing update-Virtual Tables

Source: Internet
Author: User

before change:A1Update Gls_voucher TSet t.promptval = (select sum (m.originalval)From gls_vchitem mwhere m.vid = T.vidand M.dir = 1);B1Update Gls_voucher TSet t.promptexplain = (select Max (n.explain)From gls_vchitem nwhere n.vid = T.vidand n.viid =(select min (m.viid)From gls_vchitem mwhere m.vid = N.vidAnd M.explain is not null));
after the change:A1 'Update (select n.yr, N.promptval, A.originalval newval From gls_voucher n Inner join (select m.vid, sum(m.originalval) OriginalvalFrom gls_vchitem m where m.dir = 1 Group by M.vid) a on n.vid = a.vid) T Set t.promptval = T.newval;B1 'Update (select n.yr, N.promptexplain, Q.explain newexplain From gls_voucher n Inner join (select p.vid, Max(p.explain) explainFrom Gls_vchitem p Inner join (select m.vid, min(m.viid) viidFrom gls_vchitem m where m.explain is not null Group by M.vid) a on p.viid = A.viid Group by P.vid) Q on n.vid = q.vid) T Set t.promptexplain = T.newexplain;
--The statement below will errorORA-01779: Cannot modify a column corresponding to a non-key-value Save tableDescription:Gls_voucher Voucher (vid primary Key)with theGls_vchitem Voucher Entry (VIId PRIMARY Key)throughvid correlationPurpose: Update voucherpromptexplain= The first clause in the voucher entry under the voucherexplain is not empty.Explain value
cause: After a second inner join association, Oracle cannot determinegls_voucher N andGls_vchitem P is a one-to-one query, changed to the above B1 ' on the lineUpdate (select N.yr, N.promptexplain, P.explain newexplain from Gls_voucher n inner join (select M.vid, M                     In (M.VIID) viid from Gls_vchitem m where m.explain are NOT null Group by M.vid) A on n.vid = A.vid inner join Gls_vchitem p on a.viid = p.viid) T set T.promptexplain = T.newe Xplain

Optimizing update-Virtual Tables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.