"Oracle Forms" Code

For those who understand Oracle Forms programming, the following code fragments are provided to demonstrate how files are uploaded to the database and viewed individually by users.

Upload

The following fragment is used by our Oracle Forms application to upload Microsoft Word and PDF files.

declare

 verb_cnt NUMBER := 0;

 verb_name varchar2(20);

 verb_index NUMBER;

begin

  if :hotdoc.hdocname is not null

    then message('Please press the Add button first');message(' ',no_acknowledge);

         return;

  end if;

  forms_ole.initialize_container('hotdoc.hdocument','a.a');

  :display_name := get_file_name(null,null,'PDF Files (*.PDF)/*.PDF/Word Files (*.DOC)/*.DOC/',null,OPEN_FILE,TRUE);

  if :display_name is not null

    then forms_ole.initialize_container('hotdoc.hdocument',:display_name);

         :hdocname := substr(:display_name,instr(:display_name,'\',-1,1)+1);

  end if;

end;

View

The following code is used by our Oracle Forms application to allow users the ability to view the previously-uploaded files. When this runs, the selected file opens in Microsoft Word or Adobe Acrobat.

declare

 verb_cnt NUMBER := 0;

 verb_name varchar2(20);

 verb_index NUMBER;

begin

 verb_cnt := to_number(forms_ole.get_verb_count('hotdoc.hdocument'));

 if verb_cnt > 0 then

 for loop_cnt in 1..verb_cnt loop

   verb_name := forms_ole.get_verb_name('hotdoc.hdocument',verb_cnt);

   IF substr(verb_name,1,4) = 'Edit' or substr(verb_name,1,4) = 'Open' 

     THEN   EXEC_VERB('hotdoc.hdocument',verb_name); 

            exit;   

   END IF;

 end loop;

 end if;

end;


Microsoft Word Extraction Utility

The following code was provided by Oracle to batch-extract files directly from the database.

DECLARE
handle ole2.obj_type;
BEGIN
ACTIVATE_SERVER('OLE1');
handle := forms_ole.get_interface_pointer('OLE1');
BEGIN 
-- Save a document to disk 
Args :=OLE2.CREATE_ARGLIST; 
OLE2.ADD_ARG(Args, 'C:\test.doc'); -- file name
OLE2.INVOKE(handle, 'SaveAs', Args); 
OLE2.DESTROY_ARGLIST(Args); 
EXCEPTION WHEN OTHERS THEN
Message('Error');
END;
-- OLE2.RELEASE_OBJ(handle); 
END;

Last edited Aug 23, 2007 at 6:31 PM by DaddyUnit, version 8

Comments

No comments yet.