Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TEXT_IO.PUT_LINE - Fixed length file!!

Status
Not open for further replies.
Aug 15, 2002
22
0
0
GB
Hi
I am currently using the following procedure on a v6i form to extract data from a block and create a file, everything with this current procedure works fine, however, as is usually the case, my users requirment has now changed to a fixed length file rather than a '#' delimited one. I have tried numerous times to create a fixed length file but with no success, unfortunatley all fields are of variable lengths.

Does anybody have any ideas or suggestions that may point me in the right dircetion.

Cheers

James

--------------------------

PROCEDURE create_file IS
FILENAME VARCHAR2(100);
MYFILE TEXT_IO.FILE_TYPE;
BEGIN
GO_BLOCK ('jc1');
IF :SYSTEM.BLOCK_STATUS != 'NEW' THEN
FIRST_RECORD;
MYFILE := TEXT_IO.FOPEN ('C:\test-'||sysdate||'.TXT', 'W');
LOOP
TEXT_IO.PUT_LINE (MYFILE,
:jc1.id_number||'#'||
:jc1.spec_code ||'#'||
:jc1.spec_desc ||'#'||
:jc1.date||'#'||
:jc1.type ||'#'||
:jc1.surname ||'#'||
:jc1.forenames ||'#'||
:jc1.date_of_birth ||'#'||
:jc1.add1 ||'#'||
:jc1.add2||'#'||
:jc1.add3 ||'#'||
:jc1.town ||'#'||
:jc1.county ||'#'||
:jc1.postcode ||'#'||
:jc1.home_phone ||'#'||
:jc1.work_phone||'#'||
:jc1.mord||'#'||
:jc1.mem_id||'#'||
:jc1.location_id||'#'||
:jc1.v||'#'||
:jc1.u);
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
END loop;
END if;
TEXT_IO.PUT_LINE (MYFILE,'END OF FILE');
message ('Data Exported for'||sysdate);
TEXT_IO.FCLOSE(MYFILE);
END;

---------------------------------
 
Could you use something like

TEXT_IO.PUT_LINE (MYFILE,
Rpad:)jc1.id_number,<size of id_number field>) ||
Rpad:)jc1.spec_code ,<size of spec_code field>) ||
.
.
etc

on each line? I'm not sure how the last item would be handled though, whether the trailing spaces would be trimmed by put_line.
 
Thanks for the help Lewisp, just one more quick question, how can I deal with a null value, e.g jc.add2 may not contain data and therefore will throw the fixed length format out.

Cheers

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top