title: Getting invalid identifier and SQL ignored errors in stored procedure in Oracle
body: <p>I am trying to create a stored procedure in order to insert some data into some table in Oracle 11g.</p>
  
  <p>For this purpose, I need to read the last amount from the latest insert for that user, and then add it to my new value and save the changes as a new row and if any kind of exception is occurred just rollback. This is what I have come up with so far:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE MYTESTDB.INSERT_INTO_TESTBANK
  (
    ID IN TBLTESTBANK.ID%TYPE,
    USERID IN TBLTESTBANK.USERID%TYPE,
    TYPE IN TBLTESTBANK.TYPE%TYPE,
    AMOUNT IN TBLTESTBANK.AMOUNT%TYPE,
    DATETIMESTAMP IN TBLTESTBANK.DATETIMESTAMP%TYPE,
    TRANSACTION_ID IN TBLTESTBANK.IDTRANS%TYPE,
    TOTAL_MONEY IN TBLTESTBANK.TOTALMONEY%TYPE,
    COMPUTED_HASH IN TBLTESTBANK.HASH%TYPE
    )
  IS
  
  BEGIN
    DECLARE 
    LastAmount TBLTESTBANK.TOTALMONEY%TYPE;
  
    BEGIN
        SELECT TBLTESTBANK.TOTALMONEY INTO LASTAMOUNT
        FROM 
        (
          SELECT TBLTESTBANK.ID 
          FROM TBLTESTBANK tblbnk
          WHERE tblbnk.USERID = USERID 
          order by max(tblbnk.DATETIMESTAMP)
        ) 
        where ROWNUM&lt;2;
        EXCEPTION WHEN NO_DATA_FOUND 
        THEN LastAmount := 0;        
     END;
  
    LastAmount := LastAmount+ AMOUNT;
  
    INSERT INTO TBLTESTBANK (ID, USERID, TYPE, LastAmount,
                              DATETIMESTAMP, IDTRANS, TOTALMONEY, HASH
                              )
    VALUES (ID, USERID, TYPE, AMOUNT, DATETIMESTAMP, TRANSACTION_ID, TOTAL_MONEY, COMPUTED_HASH); 
      COMMIT;
   EXCEPTION WHEN OTHERS
    THEN
    ROLLBACK;
  END;
  /
  </code></pre>
  
  <p>Whenever I try to test it, I get a red wiggly line under the first SELECT , and then he TESTBANK.ID in the inner select statements. For the select command it says, sql statement is ignored, and for the TESTBANK.ID it says invalid identifier!</p>
  
  <p>It also doesn't let me add two variables, and keeps saying LastAmount must be declared.</p>
  
  <p>And these are the errors I get : </p>
  
  <pre><code>     Error(19,7): PL/SQL: SQL Statement ignored
       Error(22,16): PL/SQL: ORA-00904: "TBLTESTBANK"."ID": invalid identifier
       Error(32,3): PLS-00201: identifier 'LASTAMOUNT' must be declared
       Error(32,3): PL/SQL: Statement ignored
       Error(34,3): PL/SQL: SQL Statement ignored
       Error(34,47): PL/SQL: ORA-00904: "LASTAMOUNT": invalid identifier
  </code></pre>