How to fetch the cursor data in oracle stored procedure

oracle

Solution

Rewrite it like this:

create or replace
PROCEDURE get_new
AS
    my_ename INTERFACE_ATTLAS.TRAFFIC_CUST_ID%TYPE;
    my_salary INTERFACE_ATTLAS.ROUTERNAME%TYPE;
    CURSOR c1 IS
    SELECT TRAFFIC_CUST_ID,ROUTERNAME
    FROM INTERFACE_ATTLAS
    WHERE rownum > 3;
BEGIN
  open c1;    
    LOOP
        FETCH c1 INTO my_ename, my_salary;
        EXIT WHEN c1%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(my_ename);
    end loop;
  close c1;
end;

Do not forget to open and close cursors. It always will print nothing because of `rownum > 3;` You wanted to type: `rownum < 3;`, didn't you?

Problem

``` create or replace PROCEDURE get_new AS CUST_ID varchar2(100); ROUTERNAME_N VARCHAR2(100); BEGIN CURSOR c1 IS SELECT TRAFFIC_CUST_ID,ROUTERNAME INTO CUST_ID,ROUTERNAME_N FROM INTERFACE_ATTLAS WHERE rownum > 3; my_ename INTERFACE_ATTLAS.TRAFFIC_CUST_ID%TYPE; my_salary INTERFACE_ATTLAS.ROUTERNAME%TYPE; LOOP FETCH c1 INTO my_ename; FETCH c1 INTO my_salary; EXIT WHEN c1%NOTFOUND; DBMS_OUTPUT.PUT_LINE(my_ename); end loop; end; ``` I am new to oracle and stored procedure. I am trying to get the rows using cursor fetch, and getting following error: ``` PLS-00103: Encountered the symbol "C1" when expecting one of the following: := . ( @ % ; ```

Original source