Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem with loop: PLS-00364: loop index variable 'REC' use is invalid

497390Aug 23 2007 — edited Aug 23 2007
Hi,

how should I change following loop:
  OPEN c FOR l_cur_sql;
  
  FOR rec IN c LOOP
    IF rec.rownum = 1 THEN
      l_line_nums := line_num;
    ELSE
      l_line_nums := l_line_nums||', '||line_num;
    END IF;
  END LOOP;
during compilation I get errror:
2476/8 PLS-00364: loop index variable 'REC' use is invalid
line no. 2476: IF rec.rownum = 1 THEN

what is wrong in this IF ?


the same problem is with following loop:
FOR rec IN (SELECT column_name, rownum  AS row_no
              FROM user_tab_columns 
              WHERE table_name = MAPDMT_TBL_NAME.Fact_Pre_Vldn(Get_Deliv_Id)  
                    AND column_name LIKE 'FACT_AMT_%' )  
  LOOP  
    IF rec.row_no = 1 THEN
      l_sel_cols := ', DECODE(TRANSLATE(REPLACE(REPLACE(TRIM('||rec.column_name||'), ''N/A''),''NA''), ''0123456789,'',''999999999999''),LPAD(''9'', LENGTH(REPLACE(REPLACE(TRIM('||rec.column_name||'),''N/A''),''NA'')),''9''),''-'',''N'') f_'||rec.column_name; 
      l_where_cols := 'f_'||rec.column_name||' = ''N'' ';
    ELSE
      l_sel_cols := l_sel_cols||', DECODE(TRANSLATE(REPLACE(REPLACE(TRIM('||rec.column_name||'), ''N/A''),''NA''), ''0123456789,'',''999999999999''),LPAD(''9'', LENGTH(REPLACE(REPLACE(TRIM('||rec.column_name||'),''N/A''),''NA'')),''9''),''-'',''N'') f_'||rec.column_name;
      l_where_cols := l_where_cols|| ' OR f_'||rec.column_name||' = ''N'' ';
    END IF;
  END LOOP;
thanks for any help/hint

--
Krzysiek
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2007
Added on Aug 23 2007
7 comments
18,492 views