Oracle 存储过程
create or replace procedure p //有就替换,没有就创建
is
cursor c is
select * from emp for update;
begin
for v_emp in c loop
if (v_emp.deptno =10) then
update emp2 set sal*2 where current of c;
elsif () then
update emp2 set sal*2 where current of c;
else
update emp2 set sal*2 where current of c;;
end if;
end loop;
commit;
end;
2、执行
exec p;
--------
begin
p;
end;
3、带参数的存储过程
create or replace procedure p
(v_a in number,v_b number,v_ret out number,v_temp in out number) //in 传的参数,out传出参数
is
begin
if(v_a>v_b) then
v_ret:=v_a;
else
v_ret :=v_b;
end if;
v_temp:=v_temp+1;
end;
使用:
declare:
v_a number :=3;
v_b number :=4;
v_ret number;
v_temp number :=5;
begin
p(v_a,v_b,v_ret,v_temp);
dbms......(v_ret);
dbmmm.....(v_temp);
end;
如果有错误 ,可以执行show error 命令显示错误信息
4、function函数
create or replace function sal_tax
(v_sal number)
return number;
is
begin
if (v_sal<2000) then
return 0.10;
elsif (v_sal<2750) then
return 0.15;
 
相关文档:
选择自 softj 的 Blog
关键字
PL/SQL实现Oracle数据库任务调度
出处
PL/SQL实现Oracle数据库任务调度
关键词:数据恢复,任务调度,ORACLE,PL/SQL
在数据库操作中时常会有这样的情况发生,由于一时的疏忽而误删或误改了一些重要的数据,另外还有 ......
在SQL语句优化过程中,我们经常会用到hint,现总结一下在SQL优化过程中常见Oracle HINT的用法:
1. /*+ALL_ROWS*/
表明对语句块选择基于开销的优化方法,并获得最佳吞吐量,使资源消耗最小化.
例如:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
2. /*+FIRST_ROWS*/
表 ......
以下列出的是Oracle
用户管理过程中常用的一些指令,以供大家参考。
Oracle
用户管理之一、创建profile
文件。
1.
SQL>Create
profile
文件名 limit
2.
  ......
1、查找表的所有索引(包括索引名,类型,构成列):
select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 要查询的表
2、查找表的主键(包括名称,构成列):
select cu.* from user_cons_columns cu, user_con ......
一、 常用日期数据格式
1.Y或YY或YYY 年的最后一位,两位或三位
SQL> Select to_char(sysdate,'Y') from dual;
TO_CHAR(SYSDATE,'Y')
--------------------
7
SQL> Select to_char(sysdate,'YY') from dual;
TO_CHAR(SYSDATE,'YY')
---------------------
07
SQL> Select to_char(sysdate,'YYY') from ......