【问题标题】:Bind variable * not declared while creating an explicit cursor绑定变量 * 在创建显式游标时未声明
【发布时间】:2020-12-12 05:33:15
【问题描述】:

尝试使用显式光标显示值,但显示以下错误。

SQL> @C:\Users\91800\Desktop\explicit.sql; SP2-0552:未声明绑定变量“C_CUST”。

代码如下:

Declare
c_id customer.id %type;
c_name customer.name %type;
c_add customer.address %type;
cursor c_cust IS select id , name , address from customers;
begin
open c_cust;
loop
    fetch c_cust into c_id , c_name , c_add;
    exit when: c_cust %not found;
    dbms_output.put_line(c_id||' '||c_name||' '||c_add);
end loop;
close c_cust;
end;
/

【问题讨论】:

    标签: oracle plsql


    【解决方案1】:

    问题在于EXIT WHEN 后面的冒号(以及其他一些小问题)。

    查看内联 cmets:

    Declare
      c_id   customer.id %type;
      c_name customer.name %type;
      c_add  customer.address %type;
      cursor c_cust IS select id , name , address from customer; -- CUSTOMER not CUSTOMERS
    begin
      open c_cust;
      loop
        fetch c_cust into c_id , c_name , c_add;
        exit when c_cust%notfound;                               -- Remove colon and spaces
        dbms_output.put_line(c_id||' '||c_name||' '||c_add);
      end loop;
      close c_cust;
    end;
    /
    

    db小提琴here

    【讨论】:

      猜你喜欢
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      • 2014-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多