Questo sito contribuisce alla audience di

La guida risponde

0 Vota

Problema con una select

Domanda

Ciao Andrea, mi chiamo Giuseppe ed ho un problema con la query che ti mando qui sotto: mi da' errore nella from view (single row subquery return more then one row). Puoi dirmi perchè? cursor c_spot is select a.bm_gb_bf_rete_trasm, a.bm_gb_bf_data_trasm, decode(a.stato_vend,'ANN',rpad(' ',5),br.br_cod_rub_bon) br_cod_rub_bon, a.int_u_cod_cli_amm, a.dur_prev, pg.SOGG, ps.NL_NT_COD_CAT_MERC cat_merceo, ps.NL_COD_CL_MERC cl_merceo, nvl(to_char(a.COD_SPOT_X_SACIS),rpad(' ',9)) COD_SPOT_X_SACIS, a.bm_gb_bf_hh_prev, a.bm_gb_bf_mn_prev, a.dp_pr_cod_piano, a.dp_pr_vers_piano, a.dp_cod_dett, decode(a.stato_vend,'ANN',rpad(' ',6),br.COD_SPOT_SACIS) COD_SPOT_SACIS, decode(a.stato_vend,'ANN',rpad(' ',25),br.DES_BR) DES_BR, nvl(sa.flag_alcoolico,' ') flag_alcolico, a.cod_spot, a.stato_vend, a.flag_rec, a.rowid, a.datamod_x_sacis, rt.stato_raitrade from rt_sogg_alcoolici sa, prosogg ps, pnsogg pg, rt_spots_stato_raitrade rt, spots a, ( select b.bm_gb_bf_data_trasm, b.bm_gb_bf_hh_prev, b.bm_gb_bf_mn_prev, b.bm_gb_bf_rete_trasm, bk.br_cod_rub_bon, bk.COD_SPOT_SACIS, bo.DES_BR, bo.segn_orar from borub bo, brkfis bk, ( select distinct s.bm_gb_bf_data_trasm, s.bm_gb_bf_hh_prev, s.bm_gb_bf_mn_prev, s.bm_gb_bf_rete_trasm from rt_spots_stato_raitrade r, spots s where s.dp_pr_cod_piano = r.sp_dp_pr_cod_piano and s.dp_pr_vers_piano = r.sp_dp_pr_vers_piano and s.dp_cod_dett = r.sp_dp_cod_dett and s.cod_spot = r.sp_cod_spot and ( (r.stato_raitrade = 'DAR' and s.bm_gb_bf_data_trasm >= per_data_da ) or (r.stato_raitrade = 'NTR' and s.STATO_VEND = 'PRE' and nvl(s.flag_rec,'X') in ('X','R','F') and s.bm_gb_bf_data_trasm between per_data_da and per_data_a ) ) ) b where bk.data_trasm (+) = b.bm_gb_bf_data_trasm and bk.rete_trasm (+) = b.bm_gb_bf_rete_trasm and bk.hh_prev (+) = b.bm_gb_bf_hh_prev and bk.mn_prev (+) = b.bm_gb_bf_mn_prev and bo.cod_rub_bon (+) = bk.BR_COD_RUB_BON and bk.rete_trasm (+) '??' ) br where nvl(br.segn_orar,'N') = 'N' and a.bm_gb_bf_data_trasm = br.bm_gb_bf_data_trasm and a.bm_gb_bf_rete_trasm = br.bm_gb_bf_rete_trasm and a.bm_gb_bf_hh_prev = br.bm_gb_bf_hh_prev and a.bm_gb_bf_mn_prev = br.bm_gb_bf_mn_prev and a.dp_pr_cod_piano = rt.sp_dp_pr_cod_piano and a.dp_pr_vers_piano = rt.sp_dp_pr_vers_piano and a.dp_cod_dett = rt.sp_dp_cod_dett and a.cod_spot = rt.sp_cod_spot and ( rt.stato_raitrade = 'DAR' or ( a.STATO_VEND = 'PRE' and nvl(a.FLAG_REC,'X') IN('X','F','R') ) ) and a.pg_pr_cod_piano = pg.pr_cod_piano (+) and a.pg_pr_vers_piano = pg.pr_vers_piano (+) and a.pg_cod_progr = pg.cod_progr (+) and ps.so_int_u_cod_interl (+) = pg.so_int_u_cod_interl and ps.so_des_sogg (+) = pg.sogg and ps.livello (+) = 1 and pg.so_int_u_cod_interl = sa.cod_cli_comm (+) and pg.sogg = sa.sogg (+) order by a.bm_gb_bf_rete_trasm, a.bm_gb_bf_data_trasm, a.bm_gb_bf_hh_prev, a.bm_gb_bf_mn_prev, a.pos_ass

Risposta

Ciao, ho analizzato a fondo la select e non ho riscontrato errori. Anzi devo dire che e' stata scritta molto bene, complimenti.

giu*** - 17 anni fa
Registrati per commentare