0

I have many tables with the same structure. One of the structure is given as follows: The table name is TRACK_CONNECTION.

Now i want to create dynamic function decrypt_password_global such that it can take dynamic input values and decrypt the password from table and return the value. I want to pass table_name,column_name,table_id,table_id_value in function as a input parameter such that while executing the function decrypt_password_global for example for TRACK_CONNECTION table i will pass (TRACK_CONNECTION,PASS,ID,11). In such way i can use decrypt_password_global function for other table also. I already created decrypt_password function for decrpytion of password and it works fine. I just want to use decrypt_password function in decrypt_password_global function for decryption of value from table.

1 Answer 1

1

build a SELECT-String and use EXECUTE IMMEDIATE / INTO :

CREATE OR REPLACE FUNCTION decrypt_password( table_name IN varchar2,column_name IN varchar2,table_id varchar2,table_id_val varchar2 ) RETURN VARCHAR2
  IS
     encrypted_pas varchar2(100);
     decrypted_pas varchar2(100);

   BEGIN
      EXECUTE IMMEDIATE 'select ' || column_name || ' from ' || table_name || ' where ' || table_id || ' = ' || table_id_val
         INTO encrypted_pas;
         Select decrypt_password(encrypted_pas) into decrypted_pas from dual;


  END decrypt_password;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.