求个创建存储过程Demo, 自己创建的怎么创都不对, 查询整个表的.
解决方案 »
- oracle10g-XE (快捷版)的client能否链接到oracle10g server(非快捷版的)数据库么?
- centura的环境配置和学习资料
- 谢谢失踪的月亮。ora-00904 在线等待
- rollback 是否关闭游标
- ???连接两个数据库
- 求助:)我的oracle开始运行正常,后来把域去掉,加入一个工作组后,不能启动,为何?
- oracle怎么卸载啊?
- 能不能用sql语句把一个数据库中的所有表的名字读出来,以及把每个表的字段名称、类型读出来?谢谢!
- sql*plus在linux下的bug??? 怎么解决?
- 判断某日期有没数据的问题
- 为什么select object_name from user_object时,表名是乱码?
- !!!多表多字段分组 在线等待!!!
create or replace procedure show_employee(empno_in in emp.empno%type)
as
v_sign number;
v_empno emp.empno%type;
v_ename emp.ename%type;
v_deptno emp.deptno%type;
begin
select 1 into v_sign
from dual
where exists(select count(*) from emp where empno=empno_in);
if v_sign=1 then
select empno,ename,deptno into v_empno,v_ename,v_deptno
from emp where empno=empno_in;
dbms_output.put_line('information of'||empno_in||' are:');
dbms_output.put_line('empno:'||v_empno||',ename:'||v_ename||',deptno:'||v_deptno);
end if;
exception
when others then
dbms_output.put_line('no data found');
end show_employee;
/
SQL> exec show_employee(7788);
PL/SQL procedure successfully completed
SQL> set serveroutput on;
SQL> /
information of7788 are:
empno:7788,ename:SCOTT,deptno:20
PL/SQL procedure successfully completed
SQL>
begin
for cursor in (select id ,type from table1 where state=1) loop
if cursor.id = 2
then update table1 set state=3 where id=cursor.id;
commit;
else
update table1 set state=4 where id=cursor.id;
commit;
end if;
end loop;
end ;
is
--声明部分
begin
--代码部分
end pro_test;
红色部分都是必须的。
in out inout 不写 ,是几种参数的形式。
in 表示只传入不传出,也就是说在代码部分,你不能更改这个参数的值。
out 表示输出参数,也就是要输出的值,可以在代码部分给它赋值。
inout 表示在代码部分可以更改它的值,也就是具备in 参数和out参数的特点。
默认情况下不写这个参数类型,为in参数。