I'm trying to use STANDARD_HASH Oracle (12c) function in PL/SQL but seems not available:
SQL> exec dbms_output.put_line(STANDARD_HASH('test'));
BEGIN dbms_output.put_line(STANDARD_HASH('test')); END;
*
ERROR at line 1:
ORA-06550: line 1, column 28:
PLS-00201: identifier 'STANDARD_HASH' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
From sql is working just fine:
SQL> select STANDARD_HASH('test') from dual;
STANDARD_HASH('TEST')
----------------------------------------
A94A8FE5CCB19BA61C4C0873D391E987982FBBD3
Why? What is the best way to implement the STANDARD_HASH in PLSQL?
Regards
For text, STANDARD_HASH is the same as DBMS_CRYPTO.HASH with SHA1:
Output:
For other data types, it's not documented how they are passed to the hash function.
Seems like it isn't yet a part of PL/SQL in
12c
.As a workaround, use
SELECT INTO
in PL/SQL:I would suggest to create a function, and use it whenever you need it in PL/SQL.
For example,
Call the function directly in PL/SQL block: