oracle - update on select ORA-01732 -


i on oracle-server ora-01732. there other issues ora, not me on situation.

i select typicaly data 2 tables , group these this:

select  sum (lg_all.hours) hour_sum,             to_char (lg_all.work_date, 'yyyy.mm') singel_month,             lg_all.exported        user usr,              user_allwc lg_all,        usr.user_id = lg_all.user_id                         , lg_all.exported = 'n'         group              to_char (lg_all.work_date, 'yyyy.mm'),             lg_all.exported    order usr.logname desc  

at next step, have set on table user_allwc:

lg_all.exported = 'y'

because of this, wrap update-statement updates-based-on-queries => inline view method:

update (   select  sum (lg_all.hours) hour_sum,                 to_char (lg_all.work_date, 'yyyy.mm') singel_month,                 lg_all.exported            user usr,                  user_allwc lg_all,            usr.user_id = lg_all.user_id                             , lg_all.exported = 'n'             group                  to_char (lg_all.work_date, 'yyyy.mm'),                 lg_all.exported        order usr.logname desc ) allg set allg.exported = 'y'; 

sadly ora-01732. can explain, when can update on select-statement , how can fix it?

from oracle sql language reference:

the view must not contain of following constructs:

  • a set operator

  • a distinct operator

  • an aggregate or analytic function

...

try simplifying - sum, group by etc. add no value anyway:

update (   select  lg_all.exported            user usr,                  user_allwc lg_all,            usr.user_id = lg_all.user_id                             , lg_all.exported = 'n'           ) allg set allg.exported = 'y'; 

as long there foreign key user_allwc user should work.

in fact, assuming there is such foreign key whole statement equivalent to:

update user_allwc    set exported = 'y'  exported = 'n'; 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -