所以我有以下功能。在我的本地oracle 11gR2上正常工作。不适用于客户端的11gR2。在dbms_lob.open失败。我的问题是'为什么'。欢迎任何帮助。
这是我到目前为止所检查的内容。 1.两个地方的Oracle目录对象权限相同。 2.我使用dbms_output.put_line检查是否正在选择所有正确的数据。 3.客户说文件位置不是问题。
顺便说一下,基本目的只是为一个文件计算一个简单的sha1(我知道,我知道,不是一个好的哈希算法)。CREATE OR REPLACE FUNCTION FC_Hash_Attachment (argAttachmentRSN int) RETURN VARCHAR2 AS
v_hash RAW(2000);
b_file BFILE;
b_file_length BINARY_INTEGER;
dst_blob BLOB;
v_dosPath Attachment.dosPath%Type;
v_truncDosPath Attachment.dosPath%Type;
v_homeDir varchar2(50);
n_count int;
BEGIN
/* This function assumes the amanda_home directory object has been created.
Further assumes the attachment is stored in the file system and not in the blob. */
/* Find the home directory so it can be stripped off the front of the dos path */
SELECT directory_path
INTO v_homeDir
FROM all_directories
WHERE UPPER(directory_name) = 'AMANDA_HOME';
DBMS_OUTPUT.PUT_LINE('v_homeDir:' || v_homeDir);
/* get the dos path of the identified attachment */
SELECT dosPath
INTO v_dosPath
FROM Attachment
WHERE attachmentRSN = argAttachmentRSN;
DBMS_OUTPUT.PUT_LINE('v_dosPath:' || v_dosPath);
/* Strip the home directory from the attachment save path */
v_truncDosPath := REPLACE(v_dosPath, v_homeDir);
DBMS_OUTPUT.PUT_LINE('v_truncDosPath:' || v_truncDosPath);
/* create a temporary blob to store the attachment in */
DBMS_LOB.CREATETEMPORARY(lob_loc => dst_blob, cache => true);
/* get the file into a bfile object */
b_file := BFILENAME('AMANDA_HOME', v_truncDosPath);
/* open the blob object as a read only */
DBMS_LOB.OPEN(b_file, DBMS_LOB.LOB_READONLY);
/* get the length of the blob object */
b_file_length := DBMS_LOB.GETLENGTH(file_loc => b_file);
/* load the file */
DBMS_LOB.LOADFROMFILE(dst_blob, b_file, b_file_length);
/* hash the file using sha1 */
v_hash := DBMS_CRYPTO.HASH(src => dst_blob, typ => DBMS_CRYPTO.HASH_SH1);
/* close the file */
DBMS_LOB.FILECLOSE(file_loc => b_file);
RETURN RAWTOHEX(v_hash);
EXCEPTION
WHEN DBMS_LOB.INVALID_ARGVAL THEN DBMS_OUTPUT.PUT_LINE ('The argument is expecting a nonNULL, valid value but the argument value passed in is NULL, invalid, or out of range.');
WHEN DBMS_LOB.ACCESS_ERROR THEN DBMS_OUTPUT.PUT_LINE('You are trying to write too much data to the LOB: LOB size is limited to 4 gigabytes.');
WHEN DBMS_LOB.NOEXIST_DIRECTORY THEN DBMS_OUTPUT.PUT_LINE('The directory leading to the file does not exist.');
WHEN DBMS_LOB.NOPRIV_DIRECTORY THEN DBMS_OUTPUT.PUT_LINE('The user does not have the necessary access privileges on the directory or the file for the operation.');
WHEN DBMS_LOB.INVALID_DIRECTORY THEN DBMS_OUTPUT.PUT_LINE('The directory used for the current operation is not valid if being accessed for the first time, or if it has been modified by the DBA since the last access.');
WHEN DBMS_LOB.OPERATION_FAILED THEN DBMS_OUTPUT.PUT_LINE('The operation attempted on the file failed.');
WHEN DBMS_LOB.UNOPENED_FILE THEN DBMS_OUTPUT.PUT_LINE('The file is not open for the required operation to be performed.');
WHEN DBMS_LOB.OPEN_TOOMANY THEN DBMS_OUTPUT.PUT_LINE('The number of open files has reached the maximum limit.');
--WHEN DBMS_LOB.NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('EndofLob indicator for looping read operations. This is not a hard error.');
--WHEN DBMS_LOB.VALUE_ERROR THEN DBMS_OUTPUT.PUT_LINE('PL/SQL error for invalid values to subprograms parameters.');
END;
他们得到的错误是 -
ORA-22288: file or LOB operation string failed string
The system could not find the specified path.