Search code examples
oracle-databasejoinplsqlcursor

CURSOR PL/SQL ORACLE


i've tried to run this cursor but i got an error that says

ERROR at line 7: ORA-06550: line 7, column 31: PLS-00357:

Table,View Or Sequence reference 'CATEGORY.CATEGORY_NAME' not allowed in this context

ORA-06550: line 7, column 1:

PL/SQL: Statement ignored

here's the pl/sql syntax that i used :

DECLARE
CURSOR check_stock IS
select category.category_name, item.item_name, item_stock from category join item on category.id_category = item.id_category;
BEGIN
FOR stock IN check
LOOP
DBMS_OUTPUT.PUT_LINE(category.category_name ||' '||item.item_name ||' '|| item.stock);
END LOOP;
END;

can somebody fix this issue ? thanks


Solution

  • You don't reference table names, but cursor variable:

    DBMS_OUTPUT.PUT_LINE(stock.category_name ||' '||stock.item_name ||' '|| stock.stock);
                         -----                      -----                   -----