Oracle存储过程总结(一、基本应用)
1、创建存储过程
create or replace procedure test(var_name_1 in type,var_name_2 out type) as
--声明变量(变量名 变量类型)
begin
--存储过程的执行体
end test;
打印出输入的时间信息
E.g:
create or replace procedure test(workDate in Date) is
begin
dbms_output.putline('The input date is:'||to_date(workDate,'yyyy-mm-dd'));
end test;
2、变量赋值
变量名 := 值;
E.g:
create or replace procedure test(workDate in Date) is
x number(4,2);
begin
x := 1;
end test;
3、判断语句:
if 比较式 then begin end; end if;
E.g
create or replace procedure test(x in number) is
begin
if x >0 then
begin
x := 0 - x;
end;
end if;
if x = 0 then
begin
x: = 1;
end;
end if;
end test;
4、For 循环
For ... in ... LOOP
--执行语句
end LOOP;
(1)循环遍历游标
create or replace procedure test() as
Cursor cursor is select name from student; name varchar(20);
begin
for name in cursor LOOP
begin
dbms_output.putline(name);
end;
end LOOP;
end test;
(2)循环遍历数组
create or replace procedure test(varArray in myPackage.TestArray) as
--(输入参数varArray 是自定义的数组类型,定义方式见标题6)
i number;
begin
i := 1; --存储过程数组是起始位置是从1开始的,与java、C、C++等语言不同。因为在Oracle中本是没有数组的概念的,数组其实就是一张
--表(Table),每个数组元素就是表中的一个记录,所以遍历数组时就相当于从表中的第一条记录开始遍历
for i in 1..varArray.count LOOP
dbms_output.putline('The No.'|| i || 'record in varArray is:'||varArray(i));
end LOOP;
end test;
5、While 循环
w
相关文档:
Just a few days ago a got to two Oracle DBAs discussing why the have so much “PX Deq Credit : send blkd” on a system. And if that is causing their performance problems.
The are some blog on the internet claiming it has to do with qc distribution and what ever.
But in many cases, especi ......
oracle wait event:cursor: pin S wait on X
cursor: pin S wait on X等待事件的处理过程
http://database.ctocio.com.cn/tips/114/8263614_1.shtml
cursor: pin S wait on X等待!
http://www.itpub.net/viewthread.php?tid=1003340
解决cursor: pin S wait on X 有什么好办法:
http://www.itpub.net/thread-1163543 ......
lengthb(string)计算string所占的字节长度 :返回字符串的长度,单位是字节
length(string)计算string所占的字符长度 :返回字符串的长度,单位是字符
对于单字节字符,LENGTHB和LENGTH是一样的.
如可以用length(‘string’)=lengthb(‘string’)判断字符串是否含有中文。
select lengt ......
一。job的运行频率设置
1.每天固定时间运行,比如早上8:10分钟:Trunc(Sysdate+1) + (8*60+10)/24*60
2.Toad中提供的:
每天:trunc(sysdate+1)
每周:trunc(sysdate+7)
每月:trunc(sysdate+30)
每个星期日:next_day(trunc(sysdate),'SUNDAY')
每天6点:trunc(sysdate+1)+6/24
半个小时:sysdate+30/1440
3.每个 ......
Blob 采用单字节存储,适合保存二进制数据,如图片、视频等。
Clob 采用多字节存储,适合保存大型文本数据。
1. 在Oracle JDBC中采用流机制对 BLOB/CLOB 进行读写操作,所以要注意不能在批处理中读写 BLOB/CLOB字段,否则将出现
Stream type cannot be used in batching 异常。
2. Oracle BLOB/CLOB 字段本身拥有一个游 ......