Fixing PLS-00302: component 'HASH_SH256' must be declared in Oracle 11g

 This error occurs when DBMS_CRYPTO.HASH_SH256 is not recognized in Oracle 11g.


✅ Step 1: Verify DBMS_CRYPTO Package Exists

Run the following query to check if DBMS_CRYPTO is installed:

SELECT * FROM all_objects WHERE object_name = 'DBMS_CRYPTO';

🔹 If no rows are returned, the package might be missing or invalid.


✅ Step 2: Grant Execution Privilege

Log in as SYSDBA and grant the required privilege:

GRANT EXECUTE ON DBMS_CRYPTO TO your_username;

🔹 Replace your_username with the actual Oracle user.


✅ Step 3: Check Supported Hashing Algorithms in Oracle 11g

Oracle 11g does not support HASH_SH256. Instead, use HASH_SH1 (SHA-1) or HASH_MD5 (MD5).
Run this to verify available hashing functions:

SELECT object_name FROM all_procedures WHERE object_name LIKE 'HASH_%' AND owner = 'SYS';

🔹 Oracle 11g supports only HASH_MD5, HASH_SH1, and HASH_SH256 (in 11.2+).


✅ Step 4: Use a Supported Hash Function

If HASH_SH256 is missing, use HASH_SH1 (SHA-1) instead:

DECLARE
v_hashed RAW(2000); BEGIN v_hashed := DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW('HelloWorld'), DBMS_CRYPTO.HASH_SH1); DBMS_OUTPUT.PUT_LINE(RAWTOHEX(v_hashed)); END; /

🔹 This will return a SHA-1 hash.


✅ Step 5: Upgrade to Oracle 12c+ (If Needed)

If you must use SHA-256, you need Oracle 12c or later. Oracle 11g does not support HASH_SH256 by default.


🔹 Summary: Fixing the Error

IssueSolution
PLS-00302: component 'HASH_SH256' must be declaredUse HASH_SH1 or HASH_MD5 instead.
ORA-00904: invalid identifier 'DBMS_CRYPTO.HASH_SH256'Check if DBMS_CRYPTO exists with SELECT * FROM all_objects WHERE object_name = 'DBMS_CRYPTO';
ORA-06550: Identifier 'DBMS_CRYPTO' must be declaredRun GRANT EXECUTE ON DBMS_CRYPTO TO your_username;

Need SHA-256 in Oracle 11g?

Since Oracle 11g doesn’t support HASH_SH256, you can implement SHA-256 manually using Java Stored Procedures or external libraries

Post a Comment

And that's all there is to it!

If anyone has any other questions or requests for future How To posts, you can either ask them in the comments or email me. Please don't feel shy at all!

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

Previous Post Next Post