所以我真的不知道为什么我的光标不起作用。select 语句工作正常,所以我不确定 SQL 服务器为什么会抛出错误。For 循环有一个隐式的打开和关闭,所以这也不应该是问题。有任何想法吗?
DECLARE
var_lname customer.c_last%TYPE;
var_fname customer.c_first%TYPE;
var_addr customer.c_address%TYPE;
var_phone customer.c_dphone%TYPE;
CURSOR expl_cursor IS SELECT c_last, c_first, c_address, c_dphone from customer;
cust_record expl_cursor%ROWTYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE('ClearWater Traders Mailing List');
FOR cust_record IN expl_cursor
LOOP
FETCH expl_cursor INTO cust_record;
var_lname := cust_record.c_last;
var_fname := cust_record.c_first;
var_addr := cust_record.c_address;
var_phone := cust_record.c_dphone;
DBMS_OUTPUT.PUT_LINE(var_lname || ' ' || var_fname || ' ' ||
var_addr || ' ' || var_phone);
END LOOP;
END;
这是错误:
第 1 行出现错误:ORA-01001:无效 cur ORA-06512:第 15 行