随笔 - 79  文章 - 11  trackbacks - 0
<2009年5月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

不再堕落。
Oracle documents: 
http://tahiti.oracle.com/

常用链接

留言簿

随笔分类(66)

随笔档案(79)

相册

收藏夹(11)

搜索

  •  

积分与排名

  • 积分 - 51971
  • 排名 - 952

最新随笔

最新评论

阅读排行榜

sys@ORCL> grant execute on dbms_crypto to mld;

授权成功。

sys
@ORCL> conn mld/mld
已连接。
mld
@ORCL> variable hash varchar2(100);
mld
@ORCL>
mld
@ORCL> begin
  
2      for x in ( select deptno, dname, loc
  
3                   from dept
  
4                  where deptno = 10 )
  
5      loop
  
6          dbms_output.put_line( 'Dname:  ' || x.dname );
  
7          dbms_output.put_line( 'Loc:    ' || x.loc );
  
8          dbms_output.put_line( 'Hash:   ' ||
  
9            dbms_crypto.hash
 
10            ( utl_raw.cast_to_raw(x.deptno||'/'||x.dname||'/'||x.loc),
 
11              dbms_crypto.hash_sh1 ) );
 
12            :hash := dbms_crypto.hash
 
13            ( utl_raw.cast_to_raw(x.deptno||'/'||x.dname||'/'||x.loc),
 
14              dbms_crypto.hash_sh1 );
 
15      end loop;
 
16  end;
 
17  /
Dname:  Accounting
Loc:    NEW YORK
Hash:   D12772FDFCDFEBE37AB8CEF4D0F38AD39A35044D

PL
/SQL 过程已成功完成。

mld
@ORCL> begin
  
2      for x in ( select deptno, dname, loc
  
3                   from dept
  
4                  where deptno = 10
  
5                    for update nowait )
  
6      loop
  
7          if ( hextoraw( :hash ) <>
  
8               dbms_crypto.hash
  
9               ( utl_raw.cast_to_raw(x.deptno||'/'||x.dname||'/'||x.loc),
 
10                 dbms_crypto.hash_sh1 ) )
 
11          then
 
12              raise_application_error(-20001'Row was modified' );
 
13          end if;
 
14      end loop;
 
15      update dept
 
16         set dname = lower(dname)
 
17       where deptno = 10;
 
18      commit;
 
19  end;
 
20  /

PL
/SQL 过程已成功完成。
------------------------------------
-- modify row in another session
------------------------------------

mld
@ORCL> /
begin
*
第 
1 行出现错误:
ORA
-20001: Row was modified
ORA
-06512: 在 line 12
posted on 2009-05-05 22:31 donnie 阅读(136) 评论(0)  编辑  收藏 所属分类: database

只有注册用户登录后才能发表评论。


网站导航: