title: SQL stored Procedure With Cursor to update a table
body: <p>I am trying to update a table using stored procedure but it is giving out an error,Please explain what is the reason. THIS is the code.</p>
  
  <pre><code>CREATE OR REPLACE Procedure UpdateItem
     ( ITEM_TYPE_NAME IN varchar2 )
  IS
      V_TABLE_NAME    VARCHAR2(100);
      V_R_TABLE_NAME  VARCHAR2(100);
      V_SQL_STMT     VARCHAR2(1000);
  
     cursor c1 is
      select C.RTARGETITEMID ||'#'||C.VERSIONID||'#'||trim(p.CREATEUSERID)||'#bsacm#CBR.CLLCT001# #/icmrm/ICMResourceManager#727665642020202020202020#2509.000000#9080#1#ICMNLSDB# #201#1#' as ITEM_REF, C.ITEMID as ITEM_ID 
      from  V_TABLE_NAME  C, V_R_TABLE_NAME R 
      where C.TIEFLAG = 0 and C.ITEMID=R.ITEMID;
  
  
  BEGIN
  
  select TABLE_NAME into V_TABLE_NAME 
  from user_indexes 
  where INDEX_NAME = (SELECT distinct c.INDEXNAME
                      FROM ICMSTNLSKEYWORDS k, ICMSTCOMPDEFS d, ICMSTTEXTINDEXES c
                      WHERE k.KEYWORDCLASS = 2 AND k.KEYWORDCODE = d.ITEMTYPEID AND d.COMPONENTTYPEID = c.COMPONENTTYPEID AND k.KEYWORDNAME = ITEM_TYPE_NAME);
  
  select TABLE_NAME into V_R_TABLE_NAME 
  from user_constraints 
  where CONSTRAINT_NAME in (select distinct R_CONSTRAINT_NAME 
                            from user_constraints 
                            where TABLE_NAME in (select TABLE_NAME 
                                                from user_indexes 
                                                where INDEX_NAME = (SELECT distinct c.INDEXNAME
                                                                    FROM ICMSTNLSKEYWORDS k, ICMSTCOMPDEFS d, ICMSTTEXTINDEXES c
                                                                    WHERE k.KEYWORDCLASS = 2 AND k.KEYWORDCODE = d.ITEMTYPEID AND d.COMPONENTTYPEID = c.COMPONENTTYPEID AND k.KEYWORDNAME=ITEM_TYPE_NAME)));
  
  open c1;
  fetch c1 into V_SQL_STMT;
  EXECUTE IMMEDIATE 'UPDATE V_TABLE_NAME set TIEFLAG = ''1'',TIEREF = c1.ITEM_REF WHERE ITEMID = ITEM.ITEM_ID';
  
  commit;
  
  close c1;
  
  EXCEPTION
  WHEN OTHERS THEN
        raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
  END;
  </code></pre>
  
  <p>And this is the error:</p>
  
  <blockquote>
    <p>Error(9,5): PL/SQL: SQL Statement
    ignored Error(10,28): PL/SQL:
    ORA-00942: table or view does not
    exist</p>
  </blockquote>