Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create Text Files Containing DBMS_OUTPUT From Forms

GusCrightonJan 16 2019 — edited Jan 24 2019

Hi

I have a procedure in the databse that creates a file in a directory and fills the file with dbms_output information

CREATE OR REPLACE PROCEDURE WRITE_TO_FILE

    IS

        v_Message       VARCHAR2(255);

        v_Status        INTEGER := 0;

        v_File_Handle   UTL_FILE.FILE_TYPE;

        cdirectory      VARCHAR2(100);

        v_File_Name     VARCHAR2(100);

        v_Write_Mode    VARCHAR2(10);

       

     BEGIN

        

         cdirectory := 'MYDIR');

        v_File_Name     := 'myfile';

        v_Write_Mode    := 'w';

                     

                       

        v_File_Handle := UTL_FILE.FOPEN(cdirectory, v_File_Name, v_Write_Mode);   

        LOOP

            EXIT WHEN v_Status = 1;

            --Status = 0 when call completes successfully, 1 when buffer is empty

            DBMS_OUTPUT.GET_LINE (v_Message, v_Status);           

            IF (v_Status = 0) THEN

                UTL_FILE.PUT_LINE(v_File_Handle, v_Message);

            END IF;

        END LOOP;       

        --Flush and close the file

        UTL_FILE.FFLUSH(v_File_Handle);

        UTL_FILE.FCLOSE(v_File_Handle);

        exception

           when others then

              dbms_output.put_line('ERROR IN WRITE_TO_FILE'||sqlerrm);

    END;

I call this procedure from another procedure using

write_to_file;

When I call this procedure from TOAD

  begin

   check_kalk(6089, 356790410029);

end;

it works, but when I call it from a form, (WHEN-MOUSE-DOUBLECLICK trigger)

KALKULATION_RESULT();

and in Program Unit KALKULATION_RESULT

IF nalert_button = ALERT_BUTTON1 -- OK

         THEN

       

       check_kalk(P_EEIREC  => :VEEIREC2001.EEIREC_NR,

                         P_AUFTRAG => :VEEIREC2003.NR_AUFTRAG_LANG);

          --       null;

     ELSE

        NULL;

    END IF;

the text file is created but it is not populated with the dbms_output.

Any ideas where I am going wrong ?

Version 11.1.2.2.0

Regards

Gus

Comments
Post Details
Added on Jan 16 2019
15 comments
1,250 views