Error in dbms_crypto.hash

I am trying to run following query in my database -
select RAWTOHEX(dbms_crypto.hash(src => UTL_I18N.STRING_TO_RAW('local123'),typ => dbms_crypto.HASH_SH1))
from dual;
But i am getting the following error message -
ORA-00907: missing right parenthesis . Error at Line 1 Column 37.
Please give me any hint why this happening? It's urgent.

Urgent it certainly is not to a forum of volunteers.
You cannot name parameters in SQL statements unless you're using Version 11, which i'll assume you aren't.
src => Is a named parameter.
How you would call this using named parameters.
ME_XE?declare
  2    whex varchar2(500);
  3  begin
  4    whex := RAWTOHEX(dbms_crypto.hash(src => UTL_I18N.STRING_TO_RAW('local123'),typ => dbms_crypto.HASH_SH1) );
  5    dbms_output.put_line(whex);
  6  end;
  7  /
B4B2E185D0513EEB159E8476ED1E0E9DD8FE85AD
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01Edited by: Tubby on May 11, 2009 1:48 PM

Similar Messages

  • Dbms_crypto.hash

    Hi ,
    create table src
    a number,
    b clob,
    c varchar2(100)
    when i execute select a,b,c from src where a=20 ,the i get 1 row .but when i use
    select a,dbms_crypto.hash(b,2),c from src where a=20 then i get an error
    ORA-01405: fetched column value is NULL
    Thanks

    Rahul  K wrote:
    Hi ,
    create table src
    a number,
    b clob,
    c varchar2(100)
    when i execute select a,b,c from src where a=20 ,the i get 1 row .but when i use
    select a,dbms_crypto.hash(b,2),c from src where a=20 then i get an error
    ORA-01405: fetched column value is NULL
    ThanksYou should know by now how to post a question on these forums. Amongst all the other things you have forgotten (like tags)
    you haven't posted your Oracle version.
    Quite important given that I can't reproduce your problem on my version (10.2.0.4.0).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Encrypt and decrypt using dbms_crypto.hash

    hi to all i am newbie here and i've just want to ask if how can i decrypt the encryted password.
    v_pass_string = 'qwerty';
    lower(dbms_crypto.hash(to_clob(v_pass_string),3))
    The out is: b1b3773a05c0ed0176787a4f1574ff0075f7521e
    and i want to output it into original data which is *'qwerty'*
    please help...
    thanks in advance

    You can't.
    HASH is not an encryption algorithm, it is a one-way hashing algorithm. HASHed cannot be converted back to the original value. This is one reason they are used for passwords as they offer the best security.
    If you want to encrypt and decrypt values you would use the ENCRYPT and DECRYPT functions of the DBMS_CRYPTO package...
    http://www.psoug.org/reference/dbms_crypto.html

  • DBMS_CRYPTO.HASH produces a different hash result when I use it in sqlldr?

    Hello,
    If I execute the following in sqlplus:
    SELECT LOWER(SYS.DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW(CONCAT('Salt','000000000')),3)) FROM DUAL;
    It produces one hash value. However, if I use similar logic in a sqlldr control file:
    OPTIONS (SKIP=7)
    LOAD DATA
    INFILE 'C:\data.csv'
    TRUNCATE INTO TABLE information
    FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    HOSTNAME          CONSTANT 'Company',
    HOSTSERVICENAME     CONSTANT 'LOB',
    ACCOUNTNAME,
    LASTNAME,
    EXTERNAL_ACCOUNT_ID     "LOWER(SYS.DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW(CONCAT('Salt',:accountname)),3))"
    Where ACCOUNTNAME in the file data.csv is also '000000000'. What am I doing wrong?
    Thanks so much,
    Jay

    user3362629 wrote:
    If anyone is interested, the problem was with the column datatype of the table. sqlldr was attempting to load data into a column of type NVARCHAR2. When I changed the column type to VARCHAR2, the hash values from both sqlldr and sqlplus were the same. I'm not sure if this is an Oracle bug or if this expected behavior. This was using Oracle Enterprise Edition 11g.Jay,
    that's very interesting. One possible explanation that I could think of: Your SQL*Plus attempt:
    If I execute the following in sqlplus:
    SELECT LOWER(SYS.DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW(CONCAT('Salt','000000000')),3)) FROM DUAL;used a VARCHAR2 literal, but the SQL*Loader code probably used a NVARCHAR2 as input to the function. From a RAW data perspective, these two, although representing the same string, could be quite different.
    You could try to do the same in SQL*Plus, by using a NVARCHAR2 input to the function. If you want to achieve that using a literal the problem is, that it's not that simple to use a NVARCHAR2 literal. You would need to use an NVARCHAR2 literal (N'000000000') and in addition probably turn on the so called "NCHAR String Literal Replacement", which means that you need to set an environment variable (ORA_NCHAR_LITERAL_REPLACE = TRUE).
    For more information regarding these issues, look here:
    Text literals: http://download.oracle.com/docs/cd/B28359_01/server.111/b28298/ch7progrunicode.htm#CACHHIFE
    NCHAR String Literal Replacement: http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements003.htm#SQLRF00218
    It's probably far simpler to use a NVARCHAR2 stored somewhere in the database, or use e.g. a concatenation of the NCHR() function to generate a NVARCHAR2 on the fly than dealing with these literal conversion issues mentioned above.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Key Lenght too short error with dbms_crypto.encrypt

    Hi Friends,
    I am getting above mentioned error with dbms_crypto.encrypt.
    I had created a thread in technology --> security forum but i am not getting any help from there.
    ORA-28234 Key Length too short with dbms_crypto.encrypt
    Appreciate if anyone help me resolve this issue.
    Thanks
    AT

    Hi Warren,
    Yes function is compiled without any compilation error.
    Thanks
    AT

  • Dbms_crypto hash for SHA-1

    I need to implement Salted SHA {SSHA} passwords by updating LDAP using PL/SQL. These values should be stored in standard Base 64 encoded format. For this I am using DBMS_CRYTO, UTL_ENCODE and DBMS_LDAP.
    However, I am finding issues with RAW values. SHA1 should have hash length of 20bytes (160bit) where as the value I am getting from dbms_crypto is coming out as 40 bytes (probably due to hex representation).
    I would like to know how to prevent this size doubling and store the string properly in the LDAP? These passwords need to be verified by LDAP authentication tools which expect base 64 encoded binary.
    Example:
    SQL>select length(dbms_crypto.hash(utl_raw.cast_to_raw('mypass'),3)) from dual;
    result: 40 (should be 20)
    I appreciate your help.
    Thanks!
    RS

    And this will get a base64 encoded hash
    select utl_raw.cast_to_varchar2( utl_encode.base64_encode( dbms_crypto.hash(utl_raw.cast_to_raw('mypass'),3) ) )
    from dual;

  • Hash created using DBMS_CRYPTO.Hash and md5sum, sha1sum not maching.

    Hi,
    I have PL/SQL script MD5SH1.sql to generate md5 and sha1 hash, but hash generated by this script and
    hash generated by md5sum and sha1sum utility not matching.
    Pl. tell me what is wrong,
    ------------------MD5SH1.sql----------------
    set serveroutput on
    DECLARE
    input_string VARCHAR2 (200) := 'Lord of the ring'';
    output_str_md5 VARCHAR2 (200);
    output_str_sh1 VARCHAR2 (200);
    hash_raw_md5 RAW(2000);
    hash_raw_sh1 RAW(2000);
    hash_algo_type1 PLS_INTEGER := DBMS_CRYPTO.HASH_MD5;
    hash_algo_type2 PLS_INTEGER := DBMS_CRYPTO.HASH_SH1;
    BEGIN
    DBMS_OUTPUT.PUT_LINE ( 'Original string: ' || input_string);
    hash_raw_md5 := DBMS_CRYPTO.Hash
    src => UTL_I18N.STRING_TO_RAW (input_string, NULL),
    --src => input_string,
    typ => hash_algo_type1
    hash_raw_sh1 := DBMS_CRYPTO.Hash
    src => UTL_I18N.STRING_TO_RAW (input_string, NULL),
    --src => input_string,
    typ => hash_algo_type2
    output_str_md5 := UTL_I18N.RAW_TO_CHAR (hash_raw_md5,'US7ASCII');
    output_str_sh1 := UTL_I18N.RAW_TO_CHAR (hash_raw_sh1,'US7ASCII');
    --output_str_md5 := hash_raw_md5;
    --output_str_sh1 := hash_raw_sh1;
    --dbms_output.put_line(hash_raw_md5);
    --dbms_output.put_line(rawtohex(hash_raw_sh1));
    DBMS_OUTPUT.PUT_LINE ('MD5 Hash: ' || output_str_md5);
    DBMS_OUTPUT.PUT_LINE ('SH1 Hash: ' || output_str_sh1);
    END;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The O/p of this script is
    SYS@mydb> @MD5SH1.sql
    Original string: Lord of the ring
    MD5 Hash: �����+.v�`�a_A
    SH1 Hash:
    ����E�k�[�F[c�2�
    PL/SQL procedure successfully completed.
    SYS@mydb>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The o/p of md5sum and sha1sum is
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [san@sde4 ~]$ echo "Lord of the ring" |md5sum
    f3fbb6dfd8a2d6f8f6aeabc4d6e17c57 -
    [san@sde4 ~]$ echo "Lord of the ring" |sha1sum
    856f6132e23c7e335ca4188bd45c7bc9515f6905 -
    [san@sde4 ~]$
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Why these 2 hashes are not matching?
    -Santosh Mhaskar

    You should take in account, that echo command adds a carriage return by default.
    SQL> set serveroutput on
    SQL> set echo on
    SQL> declare
      2    input_string       varchar2(200) := 'Lord of the ring'||chr(10);
      3    output_str_md5  varchar2(200);
      4    output_str_sh1  varchar2(200);
      5    hash_raw_md5       raw(2000);
      6    hash_raw_sh1       raw(2000);
      7    hash_algo_type1 pls_integer := dbms_crypto.hash_md5;
      8    hash_algo_type2 pls_integer := dbms_crypto.hash_sh1;
      9
    10  begin
    11    dbms_output.put_line('Original string: ' || input_string);
    12    hash_raw_md5      := dbms_crypto.hash(src => utl_raw.cast_to_raw(input_string),
    13                                       typ => hash_algo_type1);
    14    hash_raw_sh1      := dbms_crypto.hash(src => utl_raw.cast_to_raw(input_string),
    15                                       typ => hash_algo_type2);
    16    dbms_output.put_line('MD5 Hash: ' || lower(rawtohex(hash_raw_md5)));
    17    dbms_output.put_line('SH1 Hash: ' || lower(rawtohex(hash_raw_sh1)));
    18  end;
    19  /
    Original string: Lord of the ring
    MD5 Hash: f3fbb6dfd8a2d6f8f6aeabc4d6e17c57
    SH1 Hash: 856f6132e23c7e335ca4188bd45c7bc9515f6905
    PL/SQL procedure successfully completed.
    SQL> !echo "MD5 Hash:" `echo 'Lord of the ring' | md5sum`
    MD5 Hash: f3fbb6dfd8a2d6f8f6aeabc4d6e17c57 -
    SQL> !echo "SH1 Hash:" `echo 'Lord of the ring' | sha1sum`
    SH1 Hash: 856f6132e23c7e335ca4188bd45c7bc9515f6905 -Best regards
    Maxim

  • Getting runtime error while using hash table

    Hi,
    I have defined an internal table as hash with unique key.But while executng the prog. its giving a dump saying "There is already a line with the same key." My code is
      data: begin of wa_rkrp,
             vbeln like vbrk-vbeln,
             fkdat like vbrk-fkdat,
             fkart like vbrk-fkart,
             kunag like vbrk-kunag,
             knumv like vbrk-knumv,
             inco1 like vbrk-inco1,
             spart like vbrk-spart,
             netwr like vbrk-netwr,
             mwsbk like vbrk-mwsbk,
             uepos like vbrp-uepos,
             werks like vbrp-werks,
             lgort like vbrp-lgort,
            end of wa_rkrp.
      data lt_rkrp like hashed table of wa_rkrp
               with unique key vbeln
               with header line.
      select vbrk~vbeln
             vbrk~fkdat
             vbrk~fkart
             vbrk~kunag
             vbrk~knumv
             vbrk~inco1
             vbrk~spart
             vbrk~netwr
             vbrk~mwsbk
             vbrp~uepos
             vbrp~werks
             vbrp~lgort
             into table lt_rkrp
             from vbrk inner join vbrp
              on  vbrpvbeln = vbrkvbeln
             where vbrk~fkdat in s_fkdat
               and vbrk~bukrs eq p_bukrs.
    Any problem in my select query? or with my table deifnition.
    Can anyone pls suggest how to rectify this.

    define a unique key VBELN and POSNR.
    data lt_rkrp like hashed table of wa_rkrp
    with unique key vbeln posnr
    with header line.
    BTW: Stop using the header line!!! Outdated!!
    Edited by: Micky Oestreich on Mar 23, 2009 7:28 AM

  • ERROR SERIALIZING AN HASH TABLE!!!

    hi to all...
    I've a great problem...I cannot serialize my hash table...
    the values of the has table are objects (instantiations of a class of properties that I've written)
    the deserialization process launch an exception...
    java.io.NotSerializableException: FileManager, where fileManager is my class that use the hash table and that must be serialized to save his state...
    File Manager and the other class (teh value of the hash) implements serializable..
    please help me!!!!!!
    thank

    File Manager and the other class (teh value of the
    hash) implements serializable..Sure, but are all the member objects the FileManager refers to Serializable too?
    kind regards,
    Jos

  • Error PLS-201 with DBMS_CRYPTO - 11g (totally newbie error).

    Hi guys.
    I'm trying to compile a package which includes the following instruction in a function:
    return DBMS_CRYPTO.Hash(src => v_hashed, typ => DBMS_CRYPTO.HASH_MD5);
    where "v_hashed" is raw(16) and the function expects a RAW as output. This instruction works ok in 10gr2 but fails in 11g with the following error (I have been granted access to the package, of course):
    PLS-201: identified 'DMBS_CRYPTO' must be declared
    If I replicate the same functionality in an anonymous block, it works ok. I'm pretty sure there is a silly mistake I'm making but I really can't see it. Hope somebody can help me.
    TIA,
    Mariano

    You probably have permissions on dbms_crypto through a role, and not granted directly to your user. Permissions granted through a role do not work in stored procedures, but do work in anonymous blocks.
    As a quick test of this, in your sqlplus session type
    set role none;
    then try your anonymous blxok again. It will fail.
    John

  • DBMS_CRYPTO MD5 hash value does not match 3rd party MD5 free tool

    Hello,
    I am using Oracle Version: 11.2.4.
    I have a problem where the MD5 value from DBMS_CRYPTO does not match the hash value from 3rd party MD5 free tool (MD5 Checksum Calculator 0.0.5.58 or WinMD5Free v1.20) and also the MD5 hash value calculated by an ingestion tool where I am transferring files to. The MD5 hash value that the ingestion tool calculates is the same as the 3rd party MD5 free tools I have. This occurs only on some of the XML files that I generate using XSQL(xmlserialize, xmlagg, xmlelement, etc.) and DBMS_XSLPROCESSOR on a Linux OS. The XML files are transferred from the Unix OS to my Windows 7 OS via filezilla.
    I found a thread on this forum that also had a similar issue so I copy/paste the java functions. They are listed below(both are the same expect for the character set):
    create or replace java source named "MD5_UTF_8" as
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.sql.Clob;
    import java.sql.Blob;
    public class MD5_UTF_8 {
    private static final byte [] hexDigit = {
    '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
    /** Converts a byte array to a hex string
    * Returns an empty string if the byte array is null
    public static final String toHexString(byte [] bytes) {
    if (bytes == null) return new String("");
    StringBuffer buf = new StringBuffer(bytes.length * 2);
    for (int i = 0; i < bytes.length; i++) {
    buf.append((char) hexDigit[((bytes >>> 4) & 0x0F)]);
    buf.append((char) hexDigit[(bytes & 0x0F)]);
    return buf.toString();
    // Convert Hex String to Byte Array
    public static final byte[] byteArrayFromHexString(String str) {
    byte[] bytes = new byte[str.length() / 2];
    for (int i = 0; i < bytes.length; i++)
    bytes = (byte) Integer.parseInt(str.substring(2 * i, 2 * i + 2), 16);
    return bytes;
    public static String getMD5HashFromClob(Clob inhalt) throws Exception{
    MessageDigest algorithm;
    StringBuffer hexString;
    String s = null;
    String salida = null;
    int i;
    byte[] digest;
    String tepFordigest = inhalt.getSubString(1L, (int)inhalt.length());
    try {
    algorithm = MessageDigest.getInstance("MD5_UTF_8");
    algorithm.reset();
    algorithm.update(tepFordigest.getBytes("UTF-8"));
    digest = algorithm.digest();
    s = toHexString(digest);
    } catch (java.security.NoSuchAlgorithmException nsae) {
    s = "No es posible cifrar MD5";
    return s;
    sho err
    alter java source "MD5_UTF_8" compile
    sho err
    CREATE OR REPLACE FUNCTION get_md5_UTF_8_CLOB(inhalt CLOB) RETURN VARCHAR2 DETERMINISTIC
    AS LANGUAGE JAVA
    name 'MD5_UTF_8.getMD5HashFromClob(java.sql.Clob) return java.lang.String';
    create or replace java source named "MD5" as
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.sql.Clob;
    import java.sql.Blob;
    public class MD5 {
    private static final byte [] hexDigit = {
    '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
    /** Converts a byte array to a hex string
    * Returns an empty string if the byte array is null
    public static final String toHexString(byte [] bytes) {
    if (bytes == null) return new String("");
    StringBuffer buf = new StringBuffer(bytes.length * 2);
    for (int i = 0; i < bytes.length; i++) {
    buf.append((char) hexDigit[((bytes >>> 4) & 0x0F)]);
    buf.append((char) hexDigit[(bytes & 0x0F)]);
    return buf.toString();
    // Convert Hex String to Byte Array
    public static final byte[] byteArrayFromHexString(String str) {
    byte[] bytes = new byte[str.length() / 2];
    for (int i = 0; i < bytes.length; i++)
    bytes = (byte) Integer.parseInt(str.substring(2 * i, 2 * i + 2), 16);
    return bytes;
    public static String getMD5HashFromClob(Clob inhalt) throws Exception{
    MessageDigest algorithm;
    StringBuffer hexString;
    String s = null;
    String salida = null;
    int i;
    byte[] digest;
    String tepFordigest = inhalt.getSubString(1L, (int)inhalt.length());
    try {
    algorithm = MessageDigest.getInstance("MD5");
    algorithm.reset();
    algorithm.update(tepFordigest.getBytes());
    digest = algorithm.digest();
    s = toHexString(digest);
    } catch (java.security.NoSuchAlgorithmException nsae) {
    s = "No es posible cifrar MD5";
    return s;
    sho err
    alter java source "MD5" compile
    sho err
    CREATE OR REPLACE FUNCTION get_md5_CLOB(inhalt CLOB) RETURN VARCHAR2 DETERMINISTIC
    AS LANGUAGE JAVA
    name 'MD5.getMD5HashFromClob(java.sql.Clob) return java.lang.String';
    I created the above java functions and added the calls to them in my package to see what hash values they would produce but I am getting "ORA-29532: Java call terminated by uncaught Java exception: java.nio.BufferOverflowException " the XML is about 60mb.
    package code sniippets:
    declare
    l_hash raw(2000);
    l_checksum_md5 varchar2(2000);
    l_checksum_md5_utf_8 varchar2(2000);
    Begin
    t_checksum := lower(RAWTOHEX(dbms_crypto.hash(src=>l_clob,typ=>dbms_crypto.hash_md5)));
    l_hash := get_md5_CLOB (l_clob);
    l_checksum_md5 := lower(rawtohex(l_hash));
    l_hash := get_md5_UTF_8_CLOB (l_clob);
    l_checksum_md5_UTF_8 := lower(rawtohex(l_hash));Please help,
    Thank You in advance
    Don
    Edited by: 972551 on Nov 21, 2012 12:18 PM
    Edited by: sabre150 on Nov 21, 2012 11:06 PM
    Moderator action : added [code ] tags to format properly. In future please add them yourself.

    >
    I have a problem where the MD5 value from DBMS_CRYPTO does not match the hash value from 3rd party MD5 free tool (MD5 Checksum Calculator 0.0.5.58 or WinMD5Free v1.20) and also the MD5 hash value calculated by an ingestion tool where I am transferring files to. The MD5 hash value that the ingestion tool calculates is the same as the 3rd party MD5 free tools I have.
    I found a thread on this forum that also had a similar issue so I copy/paste the java functions.
    >
    And in that thread (Re: MD5 HASH computed from DBMS_CRYPTO does not match .NET MD5 I provided the reason why DBMS_CRYPTO may not match hashes produced by other methodologies.
    I have no idea why you copied and posted all of that Java code the other poster and I provided since code has NOTHING to do with the problem you say you are having. Thte other poster's question was how to write Java code that would produce the same result as DBMS_CRYPTO.
    You said your problem was understanding why DBMS_CRYPTO 'does not match the hash value from 3rd party MD5 free tool ...'. and I answered that in the other forum.
    >
    The Crypto package always converts everything to AL32UTF8 before hashing so if the .NET character set is different the hash will likely be different.
    See DBMS_CRYPTO in the PL/SQL Packages and Types doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_crypto.htm
    If you look at the spec header for the DBMS_CRYPTO package it shows this note:
    -- Prior to encryption, hashing or keyed hashing, CLOB datatype is
    -- converted to AL32UTF8. This allows cryptographic data to be
    -- transferred and understood between databases with different
    -- character sets, across character set changes and between
    -- separate processes (for example, Java programs).
    -- If your 3rd party MD5 free tool (MD5 Checksum Calculator 0.0.5.58 or WinMD5Free v1.20) do not use the AL32UTF8 character set then the hashes will likely be different. You can't modify DBMS_CRYPTO so if the hashes need to match you need to use 3rd party tools that either use the correct character set or can be configured to use the correct character set.
    The problem in the other thread was how to WRITE Java code that uses the correct character set and I showed that OP how to do that.
    So unless you are writing your own Java code all of that code you copied and pasted is useless for your use case.

  • Grant execute on DBMS_CRYPTO package (11R1)

    I figured out I needed to grant my user access to this SYS package using:
    SQL> grant execute on DBMS_CRYPTO to lob_demo;
    Grant succeeded.
    yet after doing this, I still get this error:
    SQL> select DBMS_CRYPTO.HASH(bytes, DBMS_CRYPTO.HASH_SH1) from blobslicer where id=1;
    select DBMS_CRYPTO.HASH(bytes, DBMS_CRYPTO.HASH_SH1) from blobslicer where id=1
    ERROR at line 1:
    ORA-06553: PLS-221: 'HASH_SH1' is not a procedure or is undefined
    Yet if I use the numeric constant for DBMS_CRYPTO.HASH_SH1 (3), it works:
    SQL> select DBMS_CRYPTO.HASH(bytes, 3) from blobslicer where id=1;
    F5A7338EFFEB15A49AFC9545393EF685BB51F931
    So what am I missing that prevents me from having access to a constant in the package when I can successfully use one of the function of that same package?
    Thanks, --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Maybe, that makes a little bit clearer the difference
    between usage of package constants in sql and pl sql...That's what I suspected, thank you for hammering the point home Maxim.
    The taken away for me is that package constants are not available to SQL code, only to PL/SQL code. (irrelevant of their type most likely).
    I actually tried to grant my user SELECT privileges on the package, because accessing a constant from a package is more akin to SELECT than EXECUTE, but of course one cannot do that.
    Thank you both again for the help. --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Package constants in DBMS_CRYPTO

    Anyone any idea why I can't reference the constants in the DBMS_CRYPTO package.
    I've looked in the package spec and they are there, and if I use the actual value then that works fine, but I can't reference it by name for some reason.
    SQL> create view vw_tab1 as select myid, dbms_crypto.hash(myclob, DBMS_CRYPTO.HASH_SH1) as myclob from mytab1;
    create view vw_tab1 as select myid, dbms_crypto.hash(myclob, DBMS_CRYPTO.HASH_SH1) as myclob from mytab1
    ERROR at line 1:
    ORA-06553: PLS-221: 'HASH_SH1' is not a procedure or is undefined
    SQL> create view vw_tab1 as select myid, dbms_crypto.hash(myclob, 3) as myclob from mytab1;
    View created.
    SQL>

    Hello
    It's not just dbms_crypto, it's package constants in general:
    SQL> create or replace package pkg_test
      2  as
      3  pc_test_const constant number:=1;
      4  end;
      5  /
    Package created.
    SQL> select pkg_test.pc_test_const from dual;
    select pkg_test.pc_test_const from dual
    ERROR at line 1:
    ORA-06553: PLS-221: 'PC_TEST_CONST' is not a procedure or is undefined
    SQL> select to_char(pkg_test.pc_test_const) from dual;
    select to_char(pkg_test.pc_test_const) from dual
    ERROR at line 1:
    ORA-06553: PLS-221: 'PC_TEST_CONST' is not a procedure or is undefinedI had a look in the docs to try to find the reason but I couldn't.
    HTH
    David

  • Dbms_crypto in 10g Express missing

    I have installed the Oracle Database 10g Express Edition, it works fine.
    When I tried to use the dbms_crypto-Package with e.g.
    SELECT utl_raw.cast_to_varchar2(dbms_crypto.Hash(utl_raw.cast_to_raw('My Test'),2)) FROM dual;
    I got an ORA-00904 Error.
    Have I to install something special to use the dbms_crypto-Package? I'm logged in as system, I have all privelegs on the database, have read documentation an the FAQ - but now i am helpless.
    Any idea?
    Kind regards
    Thomas

    You have to grant execute on dbms_crypto ( as user sys ) to your required user.
    SQL> select grantee from dba_tab_privs where table_name = 'DBMS_CRYPTO';
    GRANTEE
    FLOWS_030000
    FLOWS_020100
    SQL> show user
    USER is "SYS"
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - ProductionBest regards
    Maxim

  • Having problem with DBMS_CRYPTO

    Hello,
    I am trying to run this SQL statment:
    select dbms_crypto.hash(typ => dbms_crypto.HASH_MD5, src => 'TOM') from dual;
    when I do I get an Error ORA-06553: PLS-221: 'HASH_MD5' is not a procedure or is undefined
    I understand that this is because the 'HASH_MD5' is a PLSQL variable and I am trying to use it in SQL. However I need to be able to run this as a SQL statment. Any ideas how I can do this?
    Oracle version is 11.2.0.3 EE

    Sky13 wrote:
    Hello,
    I am trying to run this SQL statment:
    select dbms_crypto.hash(typ => dbms_crypto.HASH_MD5, src => 'TOM') from dual;
    when I do I get an Error ORA-06553: PLS-221: 'HASH_MD5' is not a procedure or is undefined
    I understand that this is because the 'HASH_MD5' is a PLSQL variable and I am trying to use it in SQL. However I need to be able to run this as a SQL statment. Any ideas how I can do this?
    Oracle version is 11.2.0.3 EEBeside what has just told by Adam, consider that dbms_crypto.HASH_MD5 is defined as a CONSTANT PLS_INTEGER, a type which is not available in SQL.
    The procedure, if I'm not wrong, can be called only within a PL/SQL block.
    Regards.
    Al

Maybe you are looking for