Home » SQL & PL/SQL » SQL & PL/SQL » How to Execute an external Java program from PL/SQL
How to Execute an external Java program from PL/SQL [message #214225] Mon, 15 January 2007 08:30 Go to next message
malakaus
Messages: 7
Registered: May 2005
Junior Member
Hi,

We are on Oracle 9i rel 2.

I need to execute an external Java program that does not reside inside the database from PL/SQL stored procedure.

I have a URL link to this external Java program which I need to use to trigger from the PL/sql stored procedure(this does not need a login to trigger).

I do not know how to use Java stored procedure and wanted to see if we can implement this using Pl/sql stored procedure.

Help appeciated.
Thanks
Mala.Kaushik

Re: How to Execute an external Java program from PL/SQL [message #214238 is a reply to message #214225] Mon, 15 January 2007 09:05 Go to previous messageGo to next message
BlackSwan
Messages: 25033
Registered: January 2009
Location: SoCal
Senior Member
>I have a URL link to this external Java program
DBMS_TCP might work for you.
Re: How to Execute an external Java program from PL/SQL [message #214322 is a reply to message #214225] Mon, 15 January 2007 18:40 Go to previous messageGo to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
please check if any of these samples helps.

http://www.oracle.com/technology/sample_code/tech/java/jsp/oracle9ijsp.html
rhani
Re: How to Execute an external Java program from PL/SQL [message #214492 is a reply to message #214238] Tue, 16 January 2007 13:35 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
To call an external Java program directly, just call it like any other OS command.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4021963257891

To call a Java program via a URL, first make sure you can call it from a browser, then you can call it from PL/SQL...
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:347617533333

If the call returns lots of html, you need to be careful not to chop any html tags in half. you can try logic like this (in my case I dump to file).
CREATE OR REPLACE PROCEDURE dump_page (p_dir IN VARCHAR2, p_fname IN VARCHAR2)
IS
   l_thepage   HTP.htbuf_arr;
   l_output    UTL_FILE.file_type;
   l_lines     NUMBER             DEFAULT 99999999;
   l_piece1    VARCHAR2 (255);
   l_piece2    VARCHAR2 (255);
BEGIN
   l_output    := UTL_FILE.fopen (p_dir, p_fname, 'w');
    --l_output := UTL_FILE.fopen (p_dir, p_fname, 'w', 32767 );
   OWA.get_page (l_thepage, l_lines);

   FOR i IN 1 .. l_lines
   LOOP
      l_piece1    := NULL;
      l_piece2    := NULL;

      IF INSTR (l_thepage (i), CHR (10)) > 0
      THEN
         l_piece1    := SUBSTR (l_thepage (i), 1, INSTR (l_thepage (i), CHR (10)) - 1);
         l_piece2    := SUBSTR (l_thepage (i), INSTR (l_thepage (i), CHR (10)));
         UTL_FILE.put_line (l_output, l_piece1);
         UTL_FILE.put (l_output, l_piece2);
      ELSE
         UTL_FILE.put (l_output, l_thepage (i));
      END IF;
   END LOOP;

   UTL_FILE.fclose (l_output);
END dump_page;
/
Previous Topic: PLS-00123: program too large
Next Topic: Clusters
Goto Forum:
  


Current Time: Sat Dec 03 04:00:29 CST 2016

Total time taken to generate the page: 0.16980 seconds