title: PLS 00357 Error- Table, View or Sequence "txt.col1" not allowed in the context
body: <p>I have created one <strong>Stored Procedure</strong>. In that Stored Proc I want if the value of <strong>col1</strong> &amp; <strong>col2</strong> match with employee then insert the unique record of the employee. If not found then match the value of <strong>col1</strong>, <strong>col2</strong> &amp; <strong>col3</strong> with <strong><em>employee</em></strong> match then insert the value. If also not found while match all these column then insert the record by using another column.
  Also one more thing that i want find list of values like <strong>emp_id</strong> by passing the another column value and if a single record can not <strong>match</strong> then make <strong>emp_id</strong> as <strong>NULL</strong>.</p>
  
  <pre><code>create or replace procedure sp_ex
  AS
  empID_in varchar2(10);
  fname_in varchar2(20);
  lname_in varchar2(30);
  ---------
  
  type record is ref cursor return txt%rowtype;  --Staging table
  v_rc record;
  rc rc%rowtype;
  begin
   open v_rc for select * from txt;
   loop 
   fetch v_rc into rc;
   exit when v_rc%notfound;
   loop
        select col1 from tbl1
   Where EXISTS (select col1 from tbl1 where tbl1.col1 = rc.col1);
  
  IF txt.col1 = rc.col1 AND txt.col2 = rc.col2 THEN
  insert into main_table select distinct * from txt where txt.col2 = rc.col2;
  
  ELSIF txt.col1 = rc.col1 AND txt.col2 = rc.col2 AND txt.col3 = rc.col3 THEN 
  insert into main_table select distinct * from txt where txt.col2 = rc.col2;
  
  ELSE 
  insert into main_table select * from txt where txt.col4 = rc.col4;
  end if;
  end loop;
  close v_rc;
  end sp_ex;
  </code></pre>
  
  <p>I found an error while compile this Store Procedure <code>PLS-00357: Table,View Or Sequence reference not allowed in this context</code>. How to resolve this issue and how to insert value from staging to main table while using <strong>CASE</strong> or <strong>IF ELSIF</strong> statement. Could you please help me so that i can compile the Stored Proc.</p>