oracle - ORA-01791 Pl-Sql error -
oracle - ORA-01791 Pl-Sql error -
hi guy have query give me followin error:
ora-01791: not selected look
this select expresison , please can tell me why ?
declare freqlettura varchar2(64); billingcy varchar2(64); begin freqlettura := null; billingcy := null; rec in ( select distinct(fn_get_facilityid(z.uidfacility) ) a, 1 b facilityhistory z, locality l , plant p , ztmp_sam_tb_sdv zsdv , ztmp_sam_tb_plantcode zplant , sam_tb_ca_pdr sam, meterhistory mh, meter m , meterclass mc z.uidlocality = l.uidlocality , p.uidplant = l.uidplant , z.uidaccount = zsdv.uidaccount , p.plantcode = zplant.plantcode , sam.uidfacility = z.uidfacility , z.stoptime null , sam.status = 'u' , mh.uidfacility = z.uidfacility , mh.uidmeter = m.uidmeter , m.uidmeterclass = mc.uidmeterclass , (billingcy null or p.uidbillingcycle = billingcy ) , ( ( (freqlettura = 'g') , ( mh.corrmeterid not null , mh.stoptime null , mc.maxflowmeter >= sam_fn_get_parameter_float('maxflowmet_dett_giorn')) ) or ( nvl(freqlettura,'nullo') <> 'g' , (freqlettura null or sam.readfrequency = freqlettura) ) ) , rownum = 1 order sam.stoptime, sam.uidsamtbpdr desc ) loop begin insert ztmp_sam_tb_elab_pdr (facilityid, uidbatchrequest) values (rec.a, rec.b); exception when dup_val_on_index null; end; end loop;
end;
whenever oracle error message don't understand, first thing meaning. 1 way google it. in case total description found in oracle9i database error messages is:
ora-01791 not selected look
cause: there wrong order item. query select distinct query order clause. in context, order items must constants, select list expressions, or expressions operands constants or select list expressions.
action: remove inappropriate order item select list , retry statement.
(oddly error message isn't documented in 10g or 11g manuals, despite still beingness raised!)
this matches statement have written, select distinct query trying order results column did not select.
if think it, asking doesn't create sense: selecting distinct values not include sam.stoptime (for example) may consolidating many rows different values sam.stoptime, 1 rule ordering?
also, noel's reply points out, there no reason have order clause in code anyway, solution remove it.
oracle plsql distinct
Comments
Post a Comment