改正:DECLARE i_key RAW(32); BEGIN i_key :=UTL_RAW.cast_to_raw('618272'); UPDATE SALARY SET SalaryAmount = DBMS_CRYPTO.ENCRYPT( src=>UTL_RAW.CAST_TO_RAW(TO_CHAR(SalaryAmount)), typ=>DBMS_CRYPTO.AES_CBC_PKCS5, key=>i_key, iv=>NULL ) WHERE SalaryAmount IS NOT NULL; END; /SELECT SalaryAmount FROM SALARY;
时间: 2023-12-06 11:43:04 浏览: 100
riddhi.zip_All I Have
修改后的代码如下:
DECLARE
i_key RAW(32);
BEGIN
i_key := UTL_RAW.cast_to_raw('618272');
UPDATE SALARY
SET SalaryAmount = DBMS_CRYPTO.ENCRYPT(
src => UTL_RAW.CAST_TO_RAW(TO_CHAR(SalaryAmount)),
typ => DBMS_CRYPTO.AES_CBC_PKCS5,
key => i_key,
iv => NULL
)
WHERE SalaryAmount IS NOT NULL;
COMMIT;
SELECT DBMS_CRYPTO.DECRYPT(
src => SalaryAmount,
typ => DBMS_CRYPTO.AES_CBC_PKCS5,
key => i_key,
iv => NULL
) AS Decrypted_SalaryAmount
FROM SALARY;
END;
/
这个代码块将会将 SALARY 表中的 SalaryAmount 列进行加密,并且将其更新为加密后的值。修改后的代码添加了一个 COMMIT 语句,以确保更新操作被提交。同时,还添加了一个 SELECT 语句,用于解密 SalaryAmount 并返回其原始值。
阅读全文