Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

to check if file exists on application server from forms

458094Nov 2 2006 — edited Nov 10 2006
Hello!
Web.show_document opens the file from application server in the browser.But
I want to first check whether the file exists in apllication server.I tried the following pl/sql code.But it doesn't work.

declare
my_file text_io.file_type;

flnm1 varchar2(100);

begin
flnm1:='192.168.1.53:7779/forms90/pdf/j'||:caseblock.caseyear||'/'||lower('j'||:casetype||:caseno||'.pdf');

my_file := text_io.fopen(flnm1,'R');
if text_io.is_open(my_file) then
message('opened');
message('opened');
--:parameter.file_exist := 'TRUE';
text_io.fclose(my_file);
web.show_document('http://192.168.1.53:7779/forms90/pdf/j'||:caseblock.caseyear||'/'||lower(flnm1),'_blank');

end if;
exception
when others then
if sqlcode=-302000 and not text_io.is_open(my_file) then
--:parameter.file_exist := 'FALSE';
MESSAGE('tHE fILE DOES NOT EXISTS');
MESSAGE('tHE fILE DOES NOT EXISTS');
else
--:parameter.file_exist := 'N/A';
MESSAGE('hAI');
MESSAGE('HAI');
end if;
end;

But it always executes the exception that the file does not exists.But the required file which I am searching is available in application server.

Does text_io.fopen() function will check whether the file exists in application server.
If I use the same text_io.fopen function to check if the file exists in local machine it works.

Please suggests me how to check whether a file exists in apllication server or not.
It is very urgent.

Jayashree

Comments

495035
Please check configuration of webutil.cfg file in your webutil director.
you should specify the path of directories on which are having write and read access.
such as geiven below

transfer.appsrv.read.1=c:\oracle\NFA\temp
#List transfer.appsrv.write.<n> directories
transfer.appsrv.write.1=c:\oracle\NFA\temp

this means i am having read access on c:\oracle\NFA\temp directory and i can read files from same directory. if i have not specified same u r not able to read files from that directory.

so add a directory where u r having file. like

transfer.appsrv.read.2=your directory
383213
Try pasting the link directly to the explorer and see whether it is able to find the file
for e.g your web.show_document(http://<server>:<port>/forms/<mapped folder>/<filename>) in your explorer address bar paste this "http://<server>:<port>/forms/<mapped folder>/<filename>" directly and see.
G. Krieger
flnm1:='192.168.1.53:7779/forms90/pdf/j'||:caseblock.caseyear||'/'||lower('j'||:casetype||:caseno||'.pdf');
my_file := text_io.fopen(flnm1,'R');
This won't work. text_io.fopen doesn't accept URLs. Try the physical location e.g. "c:\oracle\forms90\pdf\.....".

Gerald
458094
Hello!
web.show_document('http://192.168.1.53:7779/forms90/pdf/j'||:caseblock.caseyear||'/'||lower(flnm1),'_blank');
opens the file from browser window.I gave physical location of my pdf files in forms90.conf file in application server.That's why it is opening it in browser.
But before that I want to check whether the file which I am searching exist in application server.

Please help me to find out whether the file which I am searching exist in application server.
G. Krieger
You CAN check it with text_io.fopen, but use the physical location of the file, not the URL.

E.g. if IAS is installed on a windows machine on c:\Oracle\ then use this code:
begin
flnm1:='c:\Oracle\forms90\pdf\j'||:caseblock.caseyear||'\'||lower('j'||:casetype||:caseno||'.pdf');

my_file := text_io.fopen(flnm1,'R');
if text_io.is_open(my_file) then
message('opened');
message('opened');
--:parameter.file_exist := 'TRUE';
text_io.fclose(my_file);

Gerald
452006
Hello!
Thanks for your reply.My IAS is Linux application server.
I gave the following command
flnm1:='/forms90/pdf/j2006/test.pdf');
It didn't work out.
Then I tried the following.
flnm1:='/oracle/oas10g/IasHome/forms90/pdf/j2006/test.pdf');
It is also not working.I removed the url from from the path of the flnm1.
We are trying the above command from client system which is windows xp from forms when button pressed trigger.It still says file does not exists.

Please give your valuable suggession.
G. Krieger
Keep in mind that file names and folder names in Linux are case-sensitive (TEST.pdf and test.pdf can exist in one folder; /j2006/ and /J2006/ are two different folders).

Also make sure that the Linux user hosting the forms service has read access to '/oracle/oas10g/IasHome/forms90/pdf/j2006/' folder.

Gerald
452006
Hello!
I checked the case sensitivity also .The folder is j2006 and the file is TEST.pdf.
Actually in my forms90.conf file I have the following entries.

# virtual path for pdf
Alias Match ^/forms90/pdf/(..*) "/home2/headnote/$1".

So I gave that path only in flnm1.Still it doesnot work.Actual path where my pdf exists is /home2/headnote.But the virtual path is /forms90/pdf.
I open the pdf at web browser with web.show_document using virtual path only and it has permission to read the file.

Jayashree
G. Krieger
text_io.fopen has NOTHING to do with aliases or web.show_document!!

text_io.fopen takes the PHYSICAL path to your file, which now seems to be '/home2/headnote/j2006/TEST.pdf'.

Gerald
452006
Hello!
Thanks for yr reply.This is my code in the when button pressed trigger of my form.
I have tried the physical path also in the flnm1.Still the same error comes.
If executes the exception 'the file doesn't exists'.
What is wrong in my code?

declare
my_file text_io.file_type;
flnm1 varchar2(100);
begin
flnm1:='/home2/headnote/j'||:caseblock.caseyear||'/'||lower('j'||:casetype||:caseno||'.pdf');



message(flnm1);
message(flnm1);

my_file := text_io.fopen(flnm1,'R');
if text_io.is_open(my_file) then
message('opened');
message('opened');
--:parameter.file_exist := 'TRUE';
text_io.fclose(my_file);
web.show_document('http://192.168.1.53:7779/forms90/pdf/j'||:caseblock.caseyear||'/'||lower(flnm1),'_blank');

end if;
exception
when others then
if sqlcode=-302000 and not text_io.is_open(my_file) then
--:parameter.file_exist := 'FALSE';
MESSAGE('tHE fILE DOES NOT EXISTS');
MESSAGE('tHE fILE DOES NOT EXISTS');
else
--:parameter.file_exist := 'N/A';
MESSAGE('HAI');
MESSAGE('HAI');
end if;
end;

Once again thanks for your immediate response
G. Krieger
Try this (not tested): And again: file and folder names are case-sensitive.
declare
	my_file text_io.file_type;
	myfilename varchar2(100);
	myfoldername varchar2(100);
	flnm1 varchar2(100);
begin
-- modify these 2 lines to your needs
	myfilename := 'myfile.pdf';
	myfoldername := 'j2006';

	flnm1:='/home2/headnote/'||myfoldername||'/'||myfilename;
	message(flnm1);
	message(flnm1);
	
	my_file := text_io.fopen(flnm1,'R');
	if text_io.is_open(my_file) then
		message('opened');
		message('opened');
	--:parameter.file_exist := 'TRUE';
		text_io.fclose(my_file);
		web.show_document('http://192.168.1.53:7779/forms90/pdf/'||myfoldername||'/'||myfilename,'_blank');
	
	end if;
exception
when others then
if sqlcode=-302000 and not text_io.is_open(my_file) then 
	--:parameter.file_exist := 'FALSE'; 
	MESSAGE('tHE fILE DOES NOT EXISTS'); 
	MESSAGE('tHE fILE DOES NOT EXISTS'); 
else 
	--:parameter.file_exist := 'N/A'; 
	MESSAGE('HAI'); 
	MESSAGE('HAI'); 
end if; 
end;
458094
Hello!
Thanks for yr reply.I tried the code which you have sent also.Still the same problem is there and it executes the exception 'the file does not exist'.I checked case sensitivity in the files and folders.All my files and folders are in lower case and so I passed the file name and folder name in lowercase.Still it does not work.Is there any other solution for this problem?

Thanks.
Jayashree
492384
Hi,
are you able to get access to the pdf, if you type the complete URL as you set in your web.show_document() directly into the browser? Do you get the prompt to save this file? If not you don't have access to this file. Try that.
regards,
Heike Grüneklee
458094
Hello!
It does not open the file in browser.If I give web_show_document the file gets opened.What could be the problem?please help.

Jayashree
458094
hello!
It opens the file in browser if i give the virtual path as I give in web.show_document.For example, the following code

http://192.168.1.53:7779/forms90/pdf/j2006/ba5900h.pdf
opens the pdf file in browser.But for fopen I think we have to give the actual physical path not the virtual path
which I tried does not open it.For example

http://192.168.1.53:7779/home2/headnote/j2006/ba5900h.pdf .It says page can not be found.
458094
Hello!
If I give the virtual path like this which I give in web.show_document

http://192.168.1.53:7779/forms90/pdf/j2006/jba5900.pdf
it opens the file in browser.But if I give the actual physical path it says the page can not be found.I think for text_io.fopen we have to give the actual physical path
which does not work.Please help......

Jayashree
458094
hello!
please help to solve the above mentioned problem
G. Krieger
It seems to be a permission problem. Check the owner of the directory /home2/headnote/j2006/ and make sure that the user that runs the app server services has at least read permissions to read the file.

Gerald
458094
Hello!
If I give the virtual path like this which I give in web.show_document

http://192.168.1.53:7779/forms90/pdf/j2006/jba5900.pdf
it opens the file in browser.But if I give the actual physical path it says the page can not be found.I think for text_io.fopen we have to give the actual physical path
which does not work.Please help......

Jayashree
458094
Hello!
The owner of the file is headnote and group is headnote and I gave CHMOD 777 permission (ie) read,write and execute permission to all and others.It is not permission problem.
Thanks.

Jayashree
G. Krieger
Include the following exception handling and let us know what messages appear.
exception
 when others then
   if sqlcode = -302000 then
     loop
       exit when tool_err.nerrors = 0;
       message(to_char(tool_err.code) || ': ' || tool_err.message);
       tool_err.pop;
     end loop;
   end if; 
Gerald
492384
Hi,
try this code and create a dummy REPORTOBJECT in your module before. Should work then:


declare
my_file text_io.file_type;
myfilename varchar2(100);
myfoldername varchar2(100);
r_servername varchar2(100);
report_id report_object;
reportserverjob varchar2(100);
p_jobid int;
v_pl_id paramlist;

begin
myfoldername := 'C:\pitsscon\MIG\tool\';
myfilename := myfoldername||'file_history.rep';
r_servername := 'pitss';

report_id := find_report_object('REPORTOBJECT');
-- Reportsserver
set_report_object_property(report_id,REPORT_SERVER,r_servername);
set_report_object_propertyreport_id,REPORT_COMM_MODE,SYNCHRONOUS);
set_report_object_property(report_id,REPORT_FILENAME ,myfilename );
set_report_object_property(report_id,REPORT_DESTYPE,CACHE);
set_report_object_property(report_id,REPORT_DESFORMAT,'PDF');
set_report_object_property(report_id, REPORT_DESNAME, myfilename);

message('path '||myfilename);
message('path '||myfilename);

my_file := text_io.fopen(myfilename,'R');
if text_io.is_open(my_file) then
message('opened');
message('opened');

text_io.fclose(my_file);

reportserverjob := run_report_object(report_id,v_pl_id);

p_jobid := SUBSTR(reportserverjob, INSTR(reportserverjob, '_', -1) +1 );
message(report_object_status(reportserverjob));
message(' ');

IF report_object_status(reportserverjob) = 'FINISHED' THEN

--web.show_document('http://192.168.1.53:7779/forms90/pdf/'||myfoldername||'/'||myfilename,'_blank');
web.show_document('http://pitss-hegr:8889/reports/rwservlet/getjobid'||p_jobid||'?server='||r_servername||'_blank');
end if;
end if;

EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -302000 then
LOOP
EXIT WHEN TOOL_ERR.NERRORS = 0;
MESSAGE(TO_CHAR(TOOL_ERR.CODE) || ': ' || TOOL_ERR.MESSAGE);
TOOL_ERR.POP;
END LOOP;
END IF;
end;

regards,
Heike
458094
Hello!
Thanks for yr reply.I included the code which you have sent.But it always exit from the loop because of the following statement
exit when tool_err.nerrors = 0;
and does not execute the following instructions in the loop
message(to_char(tool_err.code) || ': ' || tool_err.message);
tool_err.pop;
and displays the message 'file does not exists' which I wrote in my code.

Jayashree
458094
Hello!
Thanks for yr reply.I don't know what is a report object and how to create it.Please tell me how to create a dummy report object in form and where to create it.

In your code you have given
r_servername := 'pitss';
I don't understand what to be given for that? what is the report server 'pitss' and in
web.show_document you wrote
web.show_document('http://pitss-hegr:8889/reports/rwservlet/getjobid'||p_jobid||'?
Is pitss-hegr is your local machine ip?
What should i give there ? Shall i give my Application server ip there? Please clarify.

Jayashree
458094
Hello!
Now I created a report object in form and tried your code.When it comes to text_io.fopen(myfilename,'R') it always executed the exception and TOOL_ERR.NERRORS = 0 and so it exits from the loop in the exception.

Jayshree
458094
Hello!
Is text_io.fopen package recognise file at client or at application server.It recognises file at my local machine but not the file at application server .Why?
What is wrong in my code

Jayashree
492384
Hi,
fine that you finally found out what a reportobject is. By the way, the forms help is a good way to get an overview about that stuff. I guess you are working at the moment directly from developer suite, aren't you? TEXT_IO is working on server side since version 9i. If you want to open a file on clientside you have to use the webutil package client_text_io instead. If I see right, you want to open a file from server, so you can work with TEXT_IO further. But it won't work from your developer if you don't have a direct access to the server. For testing your code I propose to use a local path instead. It will work from developer suite with TEXT_IO because in that case you are in a way your own server. If you want to test the application server path, test it on the application server if possible. Do you have a test environment? The advantage is that you can also test the case sensitivity of your code that is necessary on UNIX machines.
To come back you your previous questions: the variable r_servername declines the name of your report server name, either locally or of the application server. Much more elegant and dynamical would be the use of the tool_env.getvar() package but I guess for the moment this will be enough. The URL you are asking for is a combination of my localhost name divided by colon with the number of the port (have a look in your [ORACLE_HOME]/reports/conf/<reportservername>.conf to get an overview) or just ask your administrator about the correct URL for the reportserver.
Questions: First: Have you tried the my source or did you adjust it (you told that you get the message the file doesn't exist what I am not using). How did you?
Second: Does that mean you don't even get the message 'opened'? There are 3 message within my code? How many do you see?
regards,
Heike
458094
Hi!
I tried the following code.

declare
my_file text_io.file_type;
myfilename varchar2(100);
myfoldername varchar2(100);
r_servername varchar2(100);
report_id report_object;
reportserverjob varchar2(100);
p_jobid int;
v_pl_id paramlist;

begin
myfoldername := '/home2/headnote/j2006/';
myfilename := myfoldername||'jba5900.pdf';
r_servername := 'rep_nichc3';
report_id := find_report_object('REPORTOBJECT');
-- Reportsserver
set_report_object_property(report_id,REPORT_SERVER,r_servername);
set_report_object_property(report_id,REPORT_COMM_MODE,SYNCHRONOUS);
set_report_object_property(report_id,REPORT_FILENAME ,myfilename );
set_report_object_property(report_id,REPORT_DESTYPE,CACHE);
set_report_object_property(report_id,REPORT_DESFORMAT,'PDF');
set_report_object_property(report_id, REPORT_DESNAME, myfilename);

message('path '||myfilename);
message('path '||myfilename);

my_file := text_io.fopen(myfilename,'R');
if text_io.is_open(my_file) then
message('opened');
message('opened');

text_io.fclose(my_file);

reportserverjob := run_report_object(report_id,v_pl_id);

p_jobid := SUBSTR(reportserverjob, INSTR(reportserverjob, '_', -1) +1 );
message(report_object_status(reportserverjob));
message(' ');

IF report_object_status(reportserverjob) = 'FINISHED' THEN

web.show_document('http://rep_nichc3-nichc3:7779/reports/rwservlet/getjobid'||p_jobid||'?server='||r_servername||'_blank');

--web.show_document('http://pitss-hegr:8889/reports/rwservlet/getjobid'||p_jobid||'?server='||r_servername||'_blank');
end if;
end if;

EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = -302000 then
LOOP
EXIT WHEN TOOL_ERR.NERRORS = 0;
MESSAGE(TO_CHAR(TOOL_ERR.CODE) || ': ' || TOOL_ERR.MESSAGE);
TOOL_ERR.POP;
END LOOP;
END IF;
end;

From my application server /oracle/oas10g/IasHome which is our oracle home directory ,there there is one subdirectory /reports/conf I found one file rep_nichc3.conf .So I hope rep_nichc3 is our report server name.I created a dummy REPORTOBJECT also compiled the above code.No complilation errors are there.But when run the form in debug mode,it executes only one message path /home2/headnote/j2006/jba5900.pdf .After that when it enters the following if statement,
if text_io.is_open(my_file) then
if text_io.is_open(my_file) does not get satisfied so it enters the statement
IF SQLCODE = -302000 then
LOOP
EXIT WHEN TOOL_ERR.NERRORS = 0;
Here it satisfies the condition EXIT WHEN TOOL_ERR.NERRORS = 0;
and ends.No others message is getting displayed.

In my web.show_document syntax
web.show_document('http://rep_nichc3-nichc3:7779/reports/rwservlet/getjobid'||p_jobid||'?server='||r_servername||'_blank');

here rep_nichc3 is the report server name and nichc3 is my application server name.So in web_show_document I gave 'http://rep_nichc3-nichc3:7779 where 7779 is the application server port number.Here my development machine which is windows XP where developer suite is installed and application server is LINUX IAS.Both machines are in LAN and from my client I can coonect to the server.
So in web.show_document I gave the application srever address and port number etc instead of my local machine.

Still the same problem is there.Please go through my code and let me know the problem.

Thanks
Jayashree
458094
Please suggest me a solution for the above mentioned problem.I think text_io.fopen does not recognise the application server as well as the physical path of the application server /home2/headnote/j2006.Please help.It is Urgent

Jayashree
492384
Hi,
I checked the code by myself and found the following:

a) Is it possible that /home2/headnote/j2006 is only an relative path and not the absolute path? The difference is that the absolute path is beginning from the root what I can't recognize. It seems you wrote only the half path from the beginning of your users home directory (home2). Try the absolute path. The problem is definitely enrooted in the fact that the file can't be found.

b) I can't really reproduce your explanation about the values of the URL, so I try to explain it a bit clearer: the URL in web.show_document() is a combination from the following:

http://<hostname of applicationserver>:<port of ais>/<path of reportserver, mostly reports/rwservlet>/getjobid<jobid>?server=<reportservername>

Hope it works now. Otherwise you should consider what the result of your procedure has to be. Is the result that you want to run that pdf or are you more focussed on the message that the file is where it has to be? Perhaps it helps to focus more on the report. If run_report_object can't find the pdf in the path you will get an error message anyway.
regards,
Heike
458094
Hi!
Thanks for your response./home2/headnote/j2006 is the absolute path from root directory and not the relative path and I checked case sensitivity and permission of my folders as well as files.Everything is ok.My reqirement is to check whether the file is there in the folder .If it is not there,just message the user that the file is not there.If available it should open it using web.show_document.

My web.show_document code is not a problem, it is working fine if I don't check whether the file is opened using text_io.fopen.

I want a solution for whether the file is available or not .ie If file not found message the user that 'file does not exists'.

Thanks
With Regards
jayashree
458094
Hello!
Now it is working fine.The problem is I was testing the form only from Development machine which is windows Xp.I copied the fmb file into my Linux Application server and compiled in linux and run the form.It is giving the message 'file not found' it the file is not there.If the file is there it opens it in browser.Sorry for the valuable time which u have taken to answer my query.

Regards
jayashree
1 - 32
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 8 2006
Added on Nov 2 2006
32 comments
6,628 views