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!

Viewing and editing documents in Oracle forms

3002040Jun 23 2016 — edited Jun 24 2016

Hi

I have the following code for editing and viewing documents in a forms application.

The Oracle forms applciation version is 11.1.1.6.

I want to edit a docx file and i want the process id blocked when the user is editing the docx word document.

I am not able to edit a document with the extension .docx but i am able to edit .doc.

I am not able to view .pdf file in the browser as well.

I get the message  'Error removing local temporary file .'

Any help will be greatly appreciated.

Thanks

PROCEDURE EDIT_DOCUMENT(p_is_edit boolean)

IS

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

  --  Open a stored document  --

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

  v_Cmd        Varchar2(128) ;

  v_name       Varchar2(100) ;

  v_fullname   Varchar2(128);

  v_path       Varchar2(128);

  v_where      Varchar2(80);

  v_sep        Varchar2(1);

  LN$But       Pls_Integer ;

  v_ok         Boolean ;

  v_dumDate    date;

  v_cscript    Varchar2(128);

  v_fileChange boolean;

  -- Current Process ID --

  ret WEBUTIL_HOST.PROCESS_ID ;

Begin

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

    -- Local temporary file name --

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

    v_sep := WEBUTIL_FILE.Get_File_Separator ; -- 10g

    v_name := Substr( :DOC.STORED_FILE_NAME, instr( :DOC.STORED_FILE_NAME, v_sep, -1 ) + 1, 100 ) ;

    v_path := CLIENT_WIN_API_ENVIRONMENT.Get_Temp_Directory ;

    v_fullname := v_path || v_sep || v_name;

   

    -- Build where clause

    v_where := 'project_id_num = ''' || :project_id_num

             || ''' and doc_sequence_num = ' || to_char(:doc_seq_nmbr);

            

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

    -- File extraction  --

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

    If Not Webutil_File_Transfer.DB_To_Client

   (

     v_fullname,

     'PROJECT_DOCUMENT',

     'DOCUMENT_TEXT',

     v_where

   ) Then

  

        msg_popup('Error transfering local file','E',TRUE);

   End if ;

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

     -- Open the local temporary file --

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

     if :file_ext = '.doc' then

           v_Cmd := 'cmd /c start "" /WAIT WINWORD /W "' || v_fullname || '"' ;

     else    

        v_Cmd := 'cmd /c start "" /WAIT iexplore.exe -new "' || v_fullname || '"' ;

     end if;

    

     Ret := WEBUTIL_HOST.blocking( v_Cmd ) ;

   

     LN$But := WEBUTIL_HOST.Get_return_Code( Ret ) ;

     If LN$But <> 0 Then

          v_ok := WEBUTIL_FILE.DELETE_FILE( v_fullname ) ;

     msg_popup('Host() command error : ' || To_Char( LN$But ),'E',TRUE);

     End if ;

    

    

   if p_is_edit then

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

        -- Re-store the modified file in the database --

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

      If Not Webutil_File_Transfer.Client_To_DB

         (

         v_fullname,

         'PROJECT_DOCUMENT',

         'DOCUMENT_TEXT',

         v_where

         ) Then

  

         msg_popup('Error on storing file','E',FALSE);

      End if ;    

  

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

      -- create a JScript that will get file creation date and last write date --

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

      v_cscript := create_cscript_file(v_fullName);

  

      -- needed otherwise cscript file will not load, the system still

      -- thinks the file is open

      synchronize;

  

      -- Execute JScript, determine if file was modified

      if file_change(v_cscript) then

            :last_modified_date := sysdate;

      end if;

     

        v_ok := WEBUTIL_FILE.DELETE_FILE( v_cscript ) ;

    

        If v_ok = FALSE Then

             msg_popup('Error removing local temporary cscript file ' || v_cscript,'E',FALSE);

        End if ;

   end if;

        

     v_ok := WEBUTIL_FILE.DELETE_FILE( v_fullname ) ;

    

     If v_ok = FALSE Then

         msg_popup('Error removing local temporary file ' || v_fullname,'E',FALSE);

     End if ;

    

   

     Exception

          when others then

        if sqlcode <> -100501 then

           msg_popup('open_doc: ' || SQLERRM,'E',TRUE);

        end if;

      raise form_trigger_failure;

         

End EDIT_DOCUMENT ;

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

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

--  Output the text file on the client machine  --

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

FUNCTION create_cscript_file(p_fullName varchar2) return varchar2

IS

  v_file      CLIENT_TEXT_IO.FILE_TYPE;

  v_sep       Varchar2(1);

  v_path      Varchar2(128);

  v_name      Varchar2(100) := user || to_char(sysdate,'YYYYMMDDHHMISS') || '.vbs';

  v_fullname  Varchar2(128);

BEGIN

    v_sep := WEBUTIL_FILE.Get_File_Separator ; -- 10g

    v_path := CLIENT_WIN_API_ENVIRONMENT.Get_Temp_Directory ;

    v_fullname := v_path || v_sep || v_name ;

  -- Open the file --

  Begin

    v_file := CLIENT_TEXT_IO.FOPEN( v_fullname, 'W');

  Exception

      when others then

         message( 'OPEN FILE ERROR ' || v_fullname );

         raise form_trigger_failure;

  End ;

 

  -- Write the lines --

  CLIENT_TEXT_IO.PUT_LINE( v_file, 'Set objFSO = CreateObject("Scripting.FileSystemObject")' ) ;

  CLIENT_TEXT_IO.PUT_LINE( v_file, 'Set objFile = objFSO.GetFile("' || p_fullName || '")') ;     

  CLIENT_TEXT_IO.PUT_LINE( v_file, 'Wscript.Echo "DATECREATED: " & objFile.DateCreated' ) ;     

  CLIENT_TEXT_IO.PUT_LINE( v_file, 'Wscript.Echo "DATELASTMOD: " & objFile.DateLastModified' ) ;     

  -- Close the file --

  CLIENT_TEXT_IO.FCLOSE( v_file ) ;

  

   return v_fullname;

   Exception

      When form_trigger_failure Then

       CLIENT_TEXT_IO.FCLOSE( v_file ) ;     

         Raise ;

      When others then

       msg_popup('create_cscript_file: ' || sqlerrm,'F',TRUE);

END;

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2016
Added on Jun 23 2016
7 comments
1,411 views