Home » Developer & Programmer » Forms » search for a textfile which is stored in a path (oracle forms10g,Linux)
search for a textfile which is stored in a path [message #321512] Tue, 20 May 2008 09:44 Go to next message
kmkan28
Messages: 14
Registered: December 2005
Junior Member
Hi Any one help me,
Requirment is to find a name of a text file stored in a path.

this is the code for writing into a text file.

PROCEDURE PROC_FOR_CSV_FILE1( P_VAL1 CHAR,
                              P_VAL2 NUMBER
                                       )IS

  MYFILE TEXT_IO.FILE_TYPE;

  M_PARA_VALUE  VARCHAR2(50);
  M_PARA_VALUE1 VARCHAR2(50);
  
  CURSOR C1 IS
  SELECT PARA_VALUE FROM PCOM_APP_PARAMETER 
  WHERE  PARA_CODE='CSV_FILE';
  
  CURSOR C2 IS
  SELECT PARA_VALUE FROM PCOM_APP_PARAMETER 
  WHERE  PARA_CODE='CSV_FILE_HIS';

BEGIN
	  OPEN  C1;
	  FETCH C1 INTO M_PARA_VALUE;
	  CLOSE C1;
	   
	  OPEN  C2;
	  FETCH C2 INTO M_PARA_VALUE1;
	  CLOSE C2;
	  MYFILE := TEXT_IO.FOPEN(M_PARA_VALUE, 'W');
    TEXT_IO.PUTF(MYFILE, P_VAL1||',');
    TEXT_IO.PUTF(MYFILE, TO_CHAR(P_VAL2));
    TEXT_IO.PUTF(MYFILE, CHR(10)); 
    TEXT_IO.FCLOSE(MYFILE);
    EXCEPTION
    WHEN OTHERS THEN DISP_ALERT(SQLERRM);
END; 

The M_PARA_VALUE will we be having the path of the text file.

EX.d:\sample_loc\CSV\csv.txt

Requirement is to fetch the file name 'csv' and append the sysdate like csv05102008.txt and save the file name with the contents At the same location.
when i execute the code next day it has to save file name csv06102008 with the contents.

i do not want to open any dialog box using the Get_file_name command.Name has to be fetched automatically and renamed with sysdate and to save at the same location.

Can any one help me in this regard?.Thanks in advance..

Upd mod: Add 'code' tags, remove spurious CR-LFs.

[Updated on: Tue, 20 May 2008 20:04] by Moderator

Report message to a moderator

Re: search for a textfile which is stored in a path [message #321615 is a reply to message #321512] Tue, 20 May 2008 20:34 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay, a few things first.

In your code you are using three 'putf' commands. This is correct is your want your output done in three spearate lines. However, as you concatenated a ',' to the first field I assume you are trying to output this material on a single line. If this is the case, then the first should be a 'put' command and either the second also a 'put' with your third line of 'putf' with 'CHR(10)' but a 'New_Line' would be better, or just use the second line 'putf' to finish the line.

For the sysdate just use a cursor pulling a 'to_char(sysdate,'YYYYMMDD')' from 'dual' and placing it into a local variable which you use as part of your 'fopen' command'.

David
Previous Topic: problem frm-92101
Next Topic: Unable to open forms6i
Goto Forum:
  


Current Time: Fri Sep 27 12:22:20 CDT 2024