locked
PL/SQL procedure to hash clob message RRS feed

  • Question

  • Hello Experts,

    I have written the function that hashed a string but I donot know how to use this function to take in a column from another table to hash that column and then insert the hashed value into another hastable.

    any help will be appreciated,

    here is my hashing function

    CREATE OR REPLACE Function Hash_msg_clob
           (msg IN clob)
            RETURN varchar2
            AS
            hashed_value CLOB;
       
       --added
       l_timestamp_begin   varchar2(100);
       l_timestamp_end     varchar2(100);
       l_interval          varchar2(100);
       
             
      BEGIN
       
       IF msg IS NULL THEN
         dbms_output.put_line('No clob was passed');
       ELSE
          l_timestamp_begin := dbms_utility.get_time;
          
          DBMS_OUTPUT.PUT_LINE('The started time is: '||   l_timestamp_begin);
          
          SELECT STANDARD_HASH(dbms_lob.substr(msg, 4000, 1))INTO hashed_value FROM dual; --default algorithm SHA-1
          
          l_timestamp_end  := dbms_utility.get_time;
          
          DBMS_OUTPUT.PUT_LINE('The finished time is: '|| l_timestamp_end);
          
          
         
          DBMS_OUTPUT.PUT_LINE(hashed_value);
         
          l_interval       := l_timestamp_end - l_timestamp_begin;
          DBMS_OUTPUT.PUT_LINE('The interval time is: '|| l_interval/100);
          RETURN hashed_value;
          
       END IF; 
       EXCEPTION 
       WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SQLERRM);
         DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
         RAISE; 
         RETURN msg;
     END;
     

    Friday, November 27, 2020 4:38 PM

Answers

All replies

  • Hi Seham_1981,

    Thank you for posting here.

    I have moved the thread to 'where is the forum for' forum which can help you find the correct forum to go ask questions.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    Visual Basic and CLR forum will be migrating to a new home on Microsoft Q&A! (VB.NET and CLR) We invite you to post new questions in the new home on Microsoft Q&A ! For more information, please refer to the sticky post(VB.NET and CLR).

    Monday, November 30, 2020 8:02 AM
  • PL/SQL = Oracle => https://community.oracle.com/hub/

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Monday, November 30, 2020 12:02 PM