Reputation: 11
i need your help in creating loop that will go trough the rows and create txt file parameters from each row. With my current code i can't move further then first record because it is too quick(at least i think this is the reason). I want to add two second pause between each row, but i'm not quote sure how to do it. Thanks for your help!
PROCEDURE CREATE_TXT_FILE IS
out_file TEXT_IO.FILE_TYPE;
tmp_file varchar2(100);
out_str varchar2(100);
tmp_str varchar2(100);
data_str varchar2(100);
BEGIN
go_block('Block1');
FIRST_RECORD;
LOOP
TMP_FILE := 'C:\txt_files;' ------directory
TMP_FILE := TMP_FILE || 'test'; ------document name
begin
out_file := TEXT_IO.FOPEN(tmp_file, 'W');
exception
WHEN OTHERS THEN
bell;
message('Can''t open file to write.' || tmp_file,acknowledge);
raise form_trigger_failure;
END;
--parameters for text file
data_str := :block1.column1 ||:block1.column2||:block1.column3||:block1.column4||;
out_str := out_str || data_str;
begin
TEXT_IO.PUT_LINE(out_file, out_str);
exception when others then
message('Error to write string to output file. Export is aborted',acknowledge);
raise form_trigger_failure;
end;
TEXT_IO.fclose(out_file);
message('Done', no_acknowledge);
synchronize;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
END LOOP;
END;
Upvotes: 0
Views: 1149
Reputation: 142958
You shouldn't open/close the file within the loop. In other words:
Pause won't help, it'll just make the whole code way slower. If you want to know what's going on, either
message
calls into itso that you could follow the execution.
Upvotes: 1