Home » Developer & Programmer » Forms » generate text file
generate text file [message #213016] Tue, 09 January 2007 02:42 Go to next message
wreyaz
Messages: 44
Registered: April 2006
Location: Saudi Arabia
Member

I want to create a text file (emp.txt) with the following code under when_button_pressed trigger, i am using forms 10g.

Declare
Cursor C1 IS SELECT * FROM pp_emp_mast WHERE
comp = :global.comp AND STS_FLAG != 'D' AND EMPNO != 0
ORDER BY EMPNO;
x sc_circular%rowtype;
out_file CLIENT_Text_IO.File_Type;
eno char(5);
nm CHAR(45);
bs CHAR(15);
tot CHAR(15);

Begin
out_file := CLIENT_Text_IO.Fopen('c:\EMP.txt','w');
FOR x IN C1
LOOP
ENO := nvl(x.EMPNO,' ');
CLIENT_Text_IO.Put(out_file,ENO);
NM := nvl(x.ENAME,' ');
CLIENT_Text_IO.Put(out_file,NM);
BS := lpad(nvl(x.F_BASIC,0.00),10,' ');
CLIENT_Text_IO.Put(out_file,BS);
TOT := lpad(to_char(nvl(x.T_SAL,0.00)),10,' ');
CLIENT_Text_IO.Put(out_file,TOT);
CLIENT_Text_IO.New_Line(out_file,1);
END LOOP;
CLIENT_Text_IO.Fclose(out_file);
MessageBox('message','Text File Generated..');
:global.view := 'Y';
End;

The module is working without any errors, but when i press the button to generate the text file, it didn't create the 'emp.txt' file. (it does nothing).

Is there any thing missing in the code? Please help me to solve the problem.
Re: generate text file [message #213220 is a reply to message #213016] Tue, 09 January 2007 18:59 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you defined the output directory in the database? Search this forum or google for 'init.ora' or 'utl_file_dir'.

David
icon4.gif  Re: generate text file [message #213243 is a reply to message #213220] Wed, 10 January 2007 00:04 Go to previous messageGo to next message
wreyaz
Messages: 44
Registered: April 2006
Location: Saudi Arabia
Member

I forget to mention here that the 'EMP.TXT' file is created on C:\ but no data inside (blank file).
Same code is working fine in Forms 5. The only thing i change is 'text_io' to 'client_text_io'.
webutil is also configured well as it is working good with other applications.
Re: generate text file [message #213458 is a reply to message #213243] Wed, 10 January 2007 18:17 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have you placed 'message; pause;' pairs in your code to PROVE that the code is being executed and that it is not just failing on the 'open'?

David
Re: generate text file [message #213638 is a reply to message #213016] Thu, 11 January 2007 11:06 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Sounds like an empty cursor to me
Re: generate text file [message #214548 is a reply to message #213243] Wed, 17 January 2007 00:05 Go to previous messageGo to next message
wreyaz
Messages: 44
Registered: April 2006
Location: Saudi Arabia
Member

Yes I put a message like:

....
....
Begin
out_file := CLIENT_text_io.fopen('c:\EMP.txt','W');

MessageBox('message','Testing....1'); -- Success

FOR x IN C1
LOOP

MessageBox('message','Testing....2'); -- Success

ENO := nvl(x.EMPNO,' ');
CLIENT_Text_IO.Put(out_file,ENO);

MessageBox('message','Testing....3'); -- Not Success

NM := nvl(x.ENAME,' ');
CLIENT_Text_IO.Put(out_file,NM);
....
....

The file 'EMP.TXT' is created but empty.

I would like to mention here that the same code is working good with Forms 5&6.
Re: generate text file [message #214556 is a reply to message #214548] Wed, 17 January 2007 00:42 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Please check your cursor again.

David
Re: generate text file [message #215620 is a reply to message #214556] Tue, 23 January 2007 04:05 Go to previous message
wreyaz
Messages: 44
Registered: April 2006
Location: Saudi Arabia
Member

thanks all

Problem solved.
Previous Topic: Cant Done In Oracle
Next Topic: ORA-01403 error
Goto Forum:
  


Current Time: Tue Dec 03 18:50:36 CST 2024