Take the 2-minute tour ×

I have developed a solution where a PL/SQL Oracle API generates the file name of a PDF (inc. full file path) that requires printing (parameter 1) and then using the DBMS_SCHEDULER passes both that file name and a printer name (parameter 2) to the following batch file:

    "C:\Program Files (x86)\Adobe\Acrobat 4.0\Reader\AcroRd32.exe" /t %1 %2

However there are occurrences where the file name passed to the batch file does not exist. Because the file does not exist Adobe continues to run (in background). This stops the API from executing again, until someone ends the windows process manually, as the DBMS job is connected to the Adobe instance.

Unfortunately (unless there is a way in Oracle to check if the file exists in the directory) I cannot work around this issue on the Oracle side, therefore I need to tackle it on the Windows side.

Therefore is there any additional logic that I can add to the batch file or any other script that will validate the existence of the file and if the file does not exist then end the process. The solution must be efficient as the printing of the PDF files is time sensitive.

If anyone does have an Oracle side solution for this issue then I will happily supply the relevant code.

Thanks in advance.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Not launching Acrobat is easier than trying to close it. You can just check for the file existence in the batch file using the IF EXIST command:

@IF EXIST %1 (
) ELSE (
    REM optionally report error?

There are ways to check for the file from Oracle, but this is probably simpler since you already have a batch file, unless you want to test and report the error earlier in the process.

share|improve this answer
Thanks Alex, if I wanted the Else to create a text file containing %1 in order to keep track of the missing files would I do something like this: ... else ( echo %1 >> [output file/dir.txt] ) –  pwl Apr 17 '13 at 9:28
@user2075066 - yes, that would work. Not sure if you're notifying the failure back to dbms_scheduler at all, but if you are then that could potentially record the bad filename in the database instead. –  Alex Poole Apr 17 '13 at 9:35
Not at present, potential additional development in the future. At the moment I am having difficulty in tracing the cause of a dbms_scheduler job conflict (the above being one cause). The Oracle API is executed multiple times a day by multiple users, it seems that sporadically it tries to run the dbms_job whilst it is in use but I have included in the API a failsafe that will only allow the scheduler to run if it is not running. Any ideas? –  pwl Apr 17 '13 at 9:50
@user2075066 - that might be something better suited to Database Administrators I think. –  Alex Poole Apr 17 '13 at 9:52
You may be right there! Thank you for your help. –  pwl Apr 17 '13 at 9:56
add comment

Your Answer


