求个创建存储过程Demo, 自己创建的怎么创都不对, 查询整个表的.
解决方案 »
- 触发器只对刚刚操作的记录进行操作
- 有个MSSQL函数 帮忙转成ORACLE
- RedhatLinux9.0中安装了oracle9i,但现有的是oracle10g的备份文件...
- 在oracle中怎么对大型字符串数据进行插入,比如long、clob等等,在线等急用
- 请教各位大侠:oracel 中如何实现递归查询
- 怎样删除在OEM中创建的用户,等等其他删除?!
- 正版的ORACLE8i的盘,现在在任何机子上安装不上,以前用该盘装过ORACLE,不是盘的问题,我试了几个ORACLE的盘在几个不同的机子上,都安装
- 完全数据冗余?
- 由于数据文件过大,请问如何要在linux上挂载xfs文件系统?
- oracle expdp远程导出数据
- 为什么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参数。