易截截图软件、单文件、免安装、纯绿色、仅160KB

北大青鸟oracle学习笔记25

过程中的事务
定义过程p1
create or replace procedure p1
as
begin
insert into student values(5,'xdh','m',sysdate);
rollback;
end;
定义过程p2
create or replace procedure p2
as
begin
update student set stu_sex = 'a' where stu_id = 3;
p1;
end;
执行过程p2

exec p2;
执行完毕发现表中数据没有变更,说明p1中的rollback语句将p2中的update语句也回滚了。
自主事务处理
步骤:

主事务处理启动自主事务处理

主事务处理被暂停

自主事务处理sql操作

中止自主事务处理

恢复主事务处理


pragma autonomous_transaction

用于标记子程序
在p1的as begin当中加入 pragma autonomous_transaction  后执行,发行p2的update语句生效,p1中的事务作为自主事务来处理,不影响主事务。
程序包
相关对象的封装

-程序包规格说明

    声明子程序,不包含实现

create package 包名 is|as 变量声明|类型定义|异常声明|游标声明|函数说明|过程说明

pragma restrict_references(函数名,WNDS[,WNPS][,RNDS][,RNPS])

end [包名];

create or replace package StuPackages

is

  type curRefStudent is REF CURSOR RETURN student%rowtype;

  procedure insertStudent(stuid in student.stu_id%type,stuname in student.stu_name%type,stusex in student.stu_sex%type,studate in student.stu_birthday%type);
Function QueryStudent(stuid in student.stu_id%type) return student%rowtype;
end StuPackages;

-程序包主体

    定义子程序,实现声明部分

create package body 包名 is|as 变量声明|类型定义|异常声明|游标声明|函数定义|过程定义

end [包名];
CREATE OR REPLACE
PACKAGE BODY STUPACKAGES AS
procedure insertStudent(stuid in student.stu_id%type,stuname in student.stu_name%type,stusex in student.stu_sex%type,studate in student.stu_birthday%type) AS
i INTEGER;
Student_Exist EXCEPTION;
BEGIN
select count(*) into i from student where stu_id = stuid;
if i>0 then
raise Student_Exist;
else
insert into student values(stuid,stuname,stusex,studate);
commit;
end if;


相关文档:

ORACLE 10G for RHEL AS 4 安装(完整版)

ORACLE 10G for RHEL AS 4 安装
验证安装:检查ORACLE所需的程序是否安装均已安装(或更高版本)
compat-db-4.1.25-9.i386.rpm
compat-gcc-32-3.2.3-47.3.i386.rpm
compat-gcc-32-c++-3.2.3-47.3.i386.rpm
compat-libstdc++-33-3.2.3-47.3.i386.rpm
compat-oracle-rhel4-1.0-5.i386.rpm
gcc-3.4.3-9.EL4.i386.rpm
gli ......

Oracle基础学习笔记

1.sqlplus-----开启服务
2.输入用户名和密码(默认3个用户,注意,密码是可以修改的:system/manager;scott/tiger;sys/change_on_install),连接数库。
3.创建表空间:
 create tablespace 表空间逻辑名 datafile '表空间文件的物理逻辑'
 size 文件大小(如:10m) autoextend 是否自动增长文件大小(on/off ......

ORACLE 对象的使用

--创建对象类型
create or replace type emp_typ as object (
id number,
name varchar2(30),
sal number,
comm number,
member procedure change_comm(new_comm number),
member function get_info return  varchar2
) ;
--创建对象类型构造函数定义
create or replace type body emp_typ is
member proce ......

ORACLE性能诊断实例 行迁移和行链接

美国PVH DB存在行链接.通过我的检查,发现,我们的DB同样存在行迁移和行链接.ORACLE的dbms_stats.gather_schema_stats只会收集优化器统计信息,不会检测表的记录是否存在行迁移和行链接.(我原先被这个包给骗了,所以执行完dbms_stats.gather_schema_stats后一查数据字典:USER_TABLES,其中的字段chain_cnt值全为0).要检测表的记� ......

喜欢oracle这则广告

原链接:http://www.oracle.com/webapps/dialogue/dlgpage.jsp?p_ext=Y&p_dlg_id=7731619&src=6817982&Act=4&sckw=APACMK09050910MPP005.GCM.8074.110
能否在第一时间
      获得新战略的反馈意见?
能否通过管理模型
      来预测业务数据? ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号