Home » Developer & Programmer » Forms » Error in CSV file generation (merged by CM) (Oracle Forms 6i)
Error in CSV file generation (merged by CM) [message #451052] Mon, 12 April 2010 04:45 Go to next message
GKANAND
Messages: 17
Registered: June 2009
Junior Member
Hi

Im generating a csv file using TEXT_IO Utility.

The file generated contains one blank line at the last record.
Say there is 10 records. Open the generated csv file in notepad and move the cursor down. After 10 records, the cursor will move down one more time.

How to avoid that blank line as im using cursor in my script. The script is attached below.

Version:
Oracle 9i Database
Oracle Forms 6i
  • Attachment: CSVFILE.txt
    (Size: 1.11KB, Downloaded 1117 times)
Re: Error in CSV file generation (merged by CM) [message #451065 is a reply to message #451052] Mon, 12 April 2010 05:14 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Next time you post code can you please do it in the message using code tags to preserve formatting - see the orafaq forum guide if you're not sure how. Your code should appear like this:
DECLARE   

  AFILE VARCHAR2(20);
  OUT_FILE TEXT_IO.FILE_TYPE;            
  CURSOR C1 IS 
  SELECT EMP_NAME            LAST_NAME,
         EMP_SEX              SEX,
         TO_CHAR(EMP_DOB,'DD-MON-YYYY')        DATE_OF_BIRTH,
         EMP_NO              EMPLOYEE_NUMBER,
         EMP_DEPT            DEPARTMENT_NUMBER,
         EMP_BANKNR            BANK_CODE,
         EMP_BANKACC_TYPE          ACCOUNT_TYPE
  FROM EMPLOYEEMASTERTB
  ORDER BY EMP_NO;
  
BEGIN                

  IF Text_IO.Is_Open(out_file) THEN
    Text_IO.Fclose(out_file);
  END IF;                      
  AFILE  :=TO_CHAR(SYSDATE,'YYYYMMDDHHMISS');      
  out_file := Text_IO.Fopen('C:\USR\TMP\AMRUT'||AFILE||'.CSV', 'W');          
  
  FOR I IN C1 LOOP 
     
    Text_IO.Put_Line(out_file,
                     (I.LAST_NAME||'|'||
                      I.SEX||'|'||
                      I.DATE_OF_BIRTH||'|'||
                      I.EMPLOYEE_NUMBER||'|'||
                      I.DEPARTMENT_NUMBER||'|'||
                      I.BANK_CODE||'|'||
                      I.ACCOUNT_TYPE));  
        
  END LOOP;  
  
  Text_IO.Fclose (out_file);
  HOST('C:\WINDOWS\NOTEPAD.EXE C:\usr\tmp\AMRUT'||AFILE||'.CSV');  

END;


It makes it easier for the rest of us to see what you've done.
Re: Error in CSV file generation (merged by CM) [message #451352 is a reply to message #451065] Wed, 14 April 2010 02:49 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Actually, there is not a 'blank' line at the bottom of the file. There are ten 'CR-LF' characters sequences in the file. It is the program with which you are displaying the file that makes you think that there are eleven lines.

David
Previous Topic: Initial Value
Next Topic: Copy Rows from Excel Paste in Forms
Goto Forum:
  


Current Time: Fri Sep 20 10:43:47 CDT 2024