pl/sql 游标错误 ORA-06550 ORA-00905 由于缺少关键字,游标将无法编译。我真的不知道我错过了哪个关键字

pl/sql Cursor error ORA-06550 ORA-00905 Cursor will not compile because of a missing keyword. I don't really know which keyword I am missing

我正在尝试编写一个简单的游标,它将以(卖家姓氏)将产品卖给(客户姓氏)

的形式显示 SALES table 的所有销售额

这是我的光标:

DECLARE
    l_sellersurname
        seller.sellersurname%type;
    l_customersurname
        customer.customersurname%type;
        l_sale
            sale.saleid%type;
CURSOR c IS 
select * FROM SALE
BEGIN 
    for sale in c loop

  DBMS_OUTPUT.put_line (
     l_sellersurname || 
     ' sold a product to a Mr/Ms. ' || 
     l_customersurname);
end loop;
END;

我收到一个错误:

ORA-06550:第 11 行,第 6 列: PL/SQL: ORA-00905: 缺少关键字

任何人都可以给我任何解决方法的提示吗?

在光标末尾添加;:

CURSOR c IS 
select * FROM SALE;

另请注意,您没有在变量 l_sellersurname、l_customersurname、l_sale 中插入任何内容。我确信这只是某些过程或功能的开始...

假设这是程序的一部分,这是一个演示,显示在您添加之后;光标之后一切正常:https://dbfiddle.uk/?rdbms=oracle_18&fiddle=8c8cc10ac215dbbf6020070be1ef69e4

也许你想要这个:

begin
    for r in (
        select * from sale
    )
    loop
        dbms_output.put_line(r.sellersurname || ' sold a product to a Mr/Ms. ' || r.customersurname);
    end loop;
end;