title: It's not working. Can anyone help me fix it?
body: <blockquote>
    <p>I created this procedure but it said "PLS-00364: loop index variable 'DS' use is invalid" and "ORA-00942: table or view does not exist". How can I fix it?</p>
  </blockquote>
  
  <pre><code> create or replace procedure thangmax3(
          nam IN number)
      as
      begin
          nam:=&amp;nam;
          dbms_output.put_line('DS 3 thang nhieu khach den o ksan nhat nam '||nam);
          for ds in (select d.thang, d.sokhach from (select extract(month from thoigiannhan)as thang,COUNT(mathuephong)sokhach from HR.thong_tin_thue_phong 
                                      where extract(year from thoigiantra)=nam 
                                      group by  extract(month from thoigiannhan)
                                      order by COUNT(mathuephong) DESC) d 
                          where rownum&lt;=3)
          loop
              dbms_output.put_line('Thang: '||ds.thang||'     '||'So khach: '||ds.soluong);
          end loop;
      end;
  </code></pre>