Last active
December 13, 2015 20:18
-
-
Save doberkofler/4968744 to your computer and use it in GitHub Desktop.
Generate SHA1 for an Oracle Package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE | |
FUNCTION getOraclePackageSHA1(theType IN VARCHAR2, theName IN VARCHAR2) RETURN RAW | |
IS | |
TYPE aSourceType IS TABLE OF user_source.line%TYPE; | |
aSource aSourceType; | |
aLob CLOB; | |
aHash RAW(256); | |
i PLS_INTEGER; | |
BEGIN | |
SELECT Text BULK COLLECT INTO aSource FROM user_source WHERE type = UPPER(theType) AND name = UPPER(theName); | |
dbms_lob.createtemporary(lob_loc=>aLob, cache=>TRUE, dur=>dbms_lob.session); | |
i := aSource.FIRST; | |
WHILE (i IS NOT NULL) LOOP | |
dbms_lob.writeappend(lob_loc=>aLob, amount=>LENGTH(aSource(i)), buffer=>aSource(i)); | |
i := aSource.NEXT(i); | |
END LOOP; | |
aHash := dbms_crypto.hash(src=>aLob, typ=>dbms_crypto.HASH_SH1); | |
dbms_lob.freetemporary(lob_loc=>aLob); | |
RETURN aHash; | |
END getOraclePackageSHA1; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment