0

I'm trying to check if a file exists on a remote server, in a Forms 12c program unit.

I tried to use

utl_file.file_exists('\\server\d$\folder\filename.txt')

and also

utl_file.fgetattr('DBFOLDER','filename.txt',f_exists,f_length,b_size)

whereas DBFOLDER is a DB directory mapped over \server\d$\folder

file_exists works from our machine (as developers, we have access permission on server folder), but not from users' machine. fgetattr doesnt work at all.

note that file_exists works from users' machine if it searchs files in user's computer (eg: utl_file.file_exists('c:\temp\test.txt')). how can I get it works for remote server?

2 Answers 2

1

SQL and PL/SQL runs on the database server. Any directories that have been created inside the database will be accessible to the database (assuming that it has the correct read permissions). Anything that is not accessible from the database server will not be accessible within the database.

If you can map a directory from the database server to the client's C drive then you could also set up the database to be able to access that drive mapping.

However, there are usually (very good) security/privacy reasons why a server cannot access locations remote to that server (including other user's local drives) so it is unlikely that this drive mapping exists (and equally unlikely that you will be able to set it up for each user). Therefore, the practical answer to the question is that you cannot access a user's local drives from the database server (let alone from the database running on the database server).


The normal solution is to get the user to upload the file that you want to access from their computer onto the database server and then (after assuring yourself that the file is not malicious) perform whatever action you require with the uploaded file that is now residing locally to the database.

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

2 Comments

user actually should not upload any file. he just call a report; then, report server store the pdf file into a AS folder. finally, the PDF file is saved into DB using WEBUTIL_FILE_TRANSFER.ASTODBINT. it works, but we can not check if file exists on AS server, before we call WEBUTIL_FILE_TRANSFER.ASTODBINT. of course, DB server can access AS folder; furthermore, when we perform user's operation from our machine, utl_file.file_exists returns true (I think that's because we have access permission on AS folder, while users doesnt have).
im surprised how there doesn't seem to be any way to check if a file really exists on AS server, before I save it into DB
-2

In Oracle SQL, to check file existence on a remote server, use UTL_FILE or DBMS_LOB packages along with directory objects, handling exceptions to confirm if the file exists safely.

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.