Variable values in Oracle where clause I am trying to pass an variable value in my Select statement where clause, I tried a very simple query like below

Declare v_WK varchar(20);
exec :v_WK :='Wk 6'
Select * from myTable Where Column = :v_Wk


In toad it pop up the filtering window(How do I avoid that)

DATE_DIM table is like below

UNIQUE_ID   WEEK_NAME   WEEK_BEGIN  WEEK_END
1   Week 6, 2018    20180205    20180211
2   Week 5, 2018    20180129    20180204
3   Week 4, 2018    20180122    20180128
4   Week 3, 2018    20180115    20180121


And Fact Table is like

ACCT_ID WEEK_NAME   SALES
10001   20180205    10
10001   20180206    20
10001   20180207    10
10001   20180208    15
1002    20180129    100
1002    20180130    100
1002    20180131    100
1002    20180132    100


Here I need an Output like

ACCT_ID WEEK_NAME   SALES
10001   Week 6, 2018    55
1002    Week 5, 2018    406


So Basically I wanna loop each ACCT_ID like

SELECT *
FROM Fact_Table
where Week_Name between (Select Week_Begin from DATE_DIM WHERE WEEk_NAME =: v_Wknm) /* Here I will have to loop Each Week_name for Each Acct_ID */


This is what I have tried

DECLARE v_Init_Cnt NUMBER(10):=1;
        v_Tot_Cnt NUMBER(10);

BEGIN

    SELECT COUNT(*) INTO v_Tot_Cnt FROM DIM_DATE;

    WHILE(v_Init_Cnt &lt;= v_Tot_Cnt)
    LOOP

    dbms_output.put_line(v_Init_Cnt);

    VARIABLE v_Id NUMBER(10);
    exec :v_Id:= v_Init_Cnt;

    dbms_output.put_line('var' || v_Id);

    SELECT * FROM FACT_TABLE 
    WHERE WEEK_NAME between (select WEEk_BEGIN FROM DIM_DATE WHERE UNIQUE_ID :=v_Init_Cnt) and (select WEEk_END FROM DIM_DATE WHERE UNIQUE_ID :=v_Init_Cnt) 

    v_Init_Cnt :=  v_Init_Cnt +1;
    END LOOP;

END;  


Is there any efficient and correct way to do this in oracle? Thanks in Advance
Just forget all that PL/SQL mess full of incorrect syntax, this is a single query:

with date_dim as 
(
  select 1 as unique_id, 'Week 6, 2018' as week_name, 
    '20180205' as week_begin, '20180211' as week_end from dual union all
  select    1, 'Week 5, 2018', '20180129', '20180204'from dual union all
  select 1, 'Week 4, 2018', '20180122', '20180128'from dual union all
  select 1, 'Week 3, 2018', '20180115', '20180121'from dual 
),
fact as 
(
  select 10001 as acct_id, '20180205' as week_name, 10  as sales from dual union all
  select 10001 as acct_id, '20180206' as week_name, 20  as sales from dual union all
  select 10001 as acct_id, '20180207' as week_name, 10  as sales from dual union all
  select 10001 as acct_id, '20180208' as week_name, 15  as sales from dual union all
  select 1002  as acct_id, '20180129' as week_name, 100 as sales from dual union all
  select 1002  as acct_id, '20180130' as week_name, 100 as sales from dual union all
  select 1002  as acct_id, '20180131' as week_name, 100 as sales from dual union all
  select 1002  as acct_id, '20180132' as week_name, 100 as sales from dual
)
select dd.week_name, sum(f.sales) as sales from date_dim dd
join fact f on (f.week_name between dd.week_begin and dd.week_end)
group by dd.week_name
;


That gives your needed output:

WEEK_NAME         SALES
------------ ----------
Week 5, 2018        400
Week 6, 2018         55