Alex
Alex

Reputation: 11

oracle forms PL/SQL loop with pause

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

Answers (1)

Littlefoot
Littlefoot

Reputation: 142958

You shouldn't open/close the file within the loop. In other words:

  • open file
  • loop
    • write into file
  • end loop
  • close file

Pause won't help, it'll just make the whole code way slower. If you want to know what's going on, either

  • run the form in debug mode (if your Forms version allows it; 9i onward) or
  • put message calls into it

so that you could follow the execution.

Upvotes: 1

Related Questions