SQL> declare 2 i_str varchar2(10):=''; 3 num number; 4 begin 5 select count(*) into num from dept where deptno=nvl(i_str,deptno); 6 dbms_output.put_line(num); 7 end; 8 / 4PL/SQL 过程已成功完成。
CREATE OR REPLACE PROCEDURE Department_SelectAll (P_CURSOR in out department_pkg.Tab_departmentcousor) IS BEGIN if P_CURSOR%isopen then close P_CURSOR; end if; open P_CURSOR for select * from department; dbms_output('游标已成功打开'); END Department_SelectAll; /在testwindow中输入 declare -- Local variables here i integer; myc1 department_pkg.Tab_departmentcousor; begin -- Test statements here Department_SelectAll(myc1); end; 执行后,在testwindow的dbms output栏里显示"游标已成功打开"
具体怎么操作呀,就这样加上去不对啊~
2 i_str varchar2(10):='';
3 num number;
4 begin
5 select count(*) into num from dept where deptno=nvl(i_str,deptno);
6 dbms_output.put_line(num);
7 end;
8 /
4PL/SQL 过程已成功完成。
(P_CURSOR in out department_pkg.Tab_departmentcousor)
IS
BEGIN
if P_CURSOR%isopen then
close P_CURSOR;
end if;
open P_CURSOR for
select * from department;
dbms_output('游标已成功打开');
END Department_SelectAll;
/在testwindow中输入
declare
-- Local variables here
i integer;
myc1 department_pkg.Tab_departmentcousor;
begin
-- Test statements here
Department_SelectAll(myc1);
end;
执行后,在testwindow的dbms output栏里显示"游标已成功打开"
P_CURSOR%isopen boolean类型,真为正在打开,假为未打开,打开处于该状态的游标会出错;
P_CURSOR%found boolean类型,真为有数据,假为没有数据,一般紧跟在fetch语句后面
P_CURSOR%notfound boolean类型,用法与前者相反;
dbms_output.put_line()的用法:
参数可以是日期/字符/数值,长度好象不能大于1024,作用是输出参数内容到缓冲区或测试窗口的dbms output栏