复合类型:
1. 记录类型
a) Type t_record is record(
T_empno emp.empno%type,
T_ename emp.ename%type
T_row emp%rowtype
);
b) rowtype
T_row emp%rowtype := &no;
2. PL/SQL表类型(相当于数组类型)
Type dept_table_type is table of
Dept%rowtype (表中存放的数据类型) index by binary_integer(指明表的索引,即数组下标);
Index by表中的元素不一定要按任何特定的顺序排序
关键字唯一允许的类型是BINARY_INTERGER
使用主键值引用表中的字段
3. PL/SQL中的可变数组
Type string is varray(5) of number(4);
PL/SQL中的if…then…(elseif…then…)else…end
if v_sal<1500 then v_comments:='too low';
elsif v_sal<3000 then v_comments:='so so';
else v_comments:='some high';
end if;
PL/SQL中的case语句
v_comments:=
case v_grade
when 'A' then 'excellent'
when 'B' then 'very good'
when 'C' then 'good'
else 'error grade'
end;
PL/SQL 中的LOOP循环
loop
v_count:=v_count+1;
dbms_output.put_line(v_count);
exit when v_count>=10;
end loop;
PL/SQL中的wile循环
while v_count<10 loop
v_count:=v_count+1;
dbms_output.put_line(v_count);
end loop;
PL/SQL中的For循环
For v_count in(reverse) 1 。。10 loop
dbms_output.put_line(v_count);
end loop;
PL/SQL中的GoTo语句
for v_count in reverse 1..10 loop
dbms_output.put_line(v_count);
if v_count=5 then goto endogloop; end if;
end loop;
<<endogloop>>
dbms_output.put_line('end ');
PL/SQL中的占位符 null;
<<endogloop>>
Null;
预定义异常处理:
exception
when no_data_found then
dbms_output.put_line('no data found');
when too_many_rows then
dbms_output.put_line('too many rows');
when others then
dbms_output.put_line(sqlcode ||','||sqlerrm);
非预定义异常处理
Declare
deptno_remaining exception;
pragma exception_init(deptno_remaining,-2292);
begin
excption
when deptno_remaining then
dbms_output.put_line('Î¥•´ÍêÕûÐÔÔ¼Êø£¡');
dbms_output.put_line(sqlcode || ',' ||sqlerrm);
end;
自定义异常处理:
Declare
no_result exception;
begin
update dept set dname='finance' where deptno=v_deptno;
if sql%notfound then
raise no_result;
end if;
exception
when no_result then
dbms_output.put_line('no databe found');
when others then
dbms_output.put_line(sqlcode || ',' || sqlerrm);
end;
分享到:
相关推荐
Vmware+Linux+Oracle+10G+RAC全程详细图解
Oracle笔记Oracle笔记Oracle笔记Oracle笔记Oracle笔记Oracle笔记
基于Vmware 15 + CentOS 7.6 + Oracle 11g RAC+DG安装配置
Oracle+11g+在Linux平台上的安装视频教程 .Oracle+11g+在Linux平台上的安装视频教程 安装视频教程,值得收藏。
Oracle 11g RAC+DG 非常牛逼的部署手册
Oracle 培训+题目+笔记.rar (.txt.doc)
Oracle+11g+RAC+DG项目实战
oracle笔记异常处理,异常处理的代码案例和知识点笔记!
第二个压缩包
Oracle+10g+数据库管理艺术Oracle+10g+数据库管理艺术Oracle+10g+数据库管理艺术Oracle+10g+数据库管理艺术Oracle+10g+数据库管理艺术
Oracle+11g+从入门到精通 压缩文档版 欢迎各位下载阅读
手把手教你搭建 oracle 11gRAC + dg +ogg 实战文档,步骤详细,简单易懂,带你一步步走进oracle高可用。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
通过oracle jdbc thin 驱动连接oracle数据库的客户端程序,在连接中应用了SSL、钱包、双向认证、Secure External Password Store tns配置等技术,完全实战代码,非常有参考价值。
oracle linux 6.8+openfiler+oracle18c+RAC+UDEV安装文档
SQL课堂培训笔记疯汉三版【Oracle+Sqlserver+Mysql】 根据韩顺平老视的视频教程整理的笔记,PDF格式
Oracle9I ProCC++编程指南
这个是我学习网上的视频做的oracle笔记,对于oracle一窍不通的菜鸟可能有用吧,大家有需要可以看看
Oracle+11g+for+Linux+安装,本人验证过,好用