在上一篇中提到了无法使用 dbms_crypto.hash_sh1
如果使用下面的SQL进行查询, 则会出现错误:
SQL> select dbms_crypto.hash(utl_raw.cast_to_raw(10), dbms_crypto.hash_sh1)
2 from dual;
select dbms_crypto.hash(utl_raw.cast_to_raw(10), dbms_crypto.hash_sh1)
*
第 1 行出现错误:
ORA-06553: PLS-221: 'HASH_SH1' 不是过程或尚未定义
跑asktom.oracle.com上去询问了, 早上来的时候就收到email通知该问题已经回答了,
解答如下:
because dbms_crypto.hash_sh1 is a PLSQL VARIABLE.
and you are not running PLSQL - just SQL.
if you did something like:
ops$tkyte%ORA10GR2> variable x refcursor
ops$tkyte%ORA10GR2> begin
2 open :x for
3 select dbms_crypto.hash(utl_raw.cast_to_raw(10), dbms_crypto.hash_sh1)
from dual;
4 end;
5 /
PL/SQL procedure successfully completed.
ops$tkyte%ORA10GR2> print x
DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW(10),:B1)
-------------------------------------------------------------------------------
B1D5781111D84F7B3FE45A0852E59758CD7A87E5
it would work - because PLSQL detects references to PLSQL variables and replaces them with bind variables....