---
title: "关于ORACLE事务的小实例"
author: "studentGuy1"
date: "2011-03-24T18:35:00Z"
tags: ["Oracle"]
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2013-09-10T17:22:07Z"
id: 1940256
url: "https://studentguy1.iteye.com/blog/1940256"
---

declare

begin

for t in 1..10 loop

begin

insert into t\_bns\_share\_log (ID) values(nulll);/* 如果ID不能为空的情况下 \*/

exception

when others then

insert into t\_bns\_share\_log (ID) values(hibernate\_sequence.nextval);

insert into t\_bns\_share\_log (PROJECT\_CODE) values(hibernate\_sequence.nextval);/* 在之后不能执行，如果想执行这一句，则需要在exception之前操作 \*/

end;

end loop;

commit;

end;