Is it possible to call Java Code in a Oracle Trigger?

Hi there,
I am a programmer, but I need to do some Oracle database job. Specifically, I want to create a trigger in Oracle database table and within the trigger to call some java JDBC code to connect to another DB2 database. Is it possible?
If possible where to find some sample code or material?
Thank you!
Eric

Thank you for you great answer. it is clear and helpful.
but I am not very good at database. I still have question on "databaseLink".
all I know is use JDBC to connect to db.
In your code:
INSERT INTO localOracleTable
SELECT * FROM remoteDB2Table@databaseLink
BEGIN
FOR x IN (SELECT * FROM localOracleTable)
LOOP
INSERT INTO remoteDB2Table( <<column list>> )
VALUES( x.col1, x.col2, x.col3, ... x.colN );END LOOP;
END;
What the "databaseLink" look like? I want to do is other way around. select * from remoteDB2Table and insert into localOracleTable...
I will spend some time on Oracle to try to fully understand it.
Thanks a lot!
Eric

Similar Messages

  • How to call java code in xsl?

    I'm trying to call java code in xsl. I've not been able to do so so far....any help is greatly appreciated.
    Here's my xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"
              xmlns:xalan="http://xml.apache.org/xalan"
              xmlns:java="http://xml.apache.org/xalan/java"
              extension-element-prefixes="java">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="data_order">
    <order xsl:use-attribute-sets="order-info"></order>
    <fromdate><xsl:value-of select="ds/temporal/ds_start_date"/></fromdate>
    <stringdate><xsl:variable name="stringDate" select="java:ConvertDate2.changeDate(ds_start_date)"/>
    </stringdate>
    <thrudate><xsl:value-of select="ds/temporal/ds_stop_date"/></thrudate>
    <chans><xsl:apply-templates select="ds/subset_spec/channels"/></chans>
    </xsl:template>
    <xsl:attribute-set name="order-info">
    <xsl:attribute name="id"><xsl:value-of select="@job_id"/></xsl:attribute>
    <xsl:attribute name="job"><xsl:value-of select="@origin"/></xsl:attribute>
    </xsl:attribute-set>
    <xsl:template match="channels">
    <xsl:copy use-attribute-sets="sequence">
    <xsl:apply-templates/>
    </xsl:copy>
    </xsl:template>
    <xsl:attribute-set name="sequence">
    <xsl:attribute name="index"><xsl:value-of select="position()"/></xsl:attribute>
    </xsl:attribute-set>
    </xsl:stylesheet>
    And here's my java code
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    public class ConvertDate2
    public static String changeDate(String inputdate)
    String date_array[];
    String combined_date;
    date_array = inputdate.split("[-]");
    combined_date = date_array[0]+ date_array[1]+ date_array[2];
    return combined_date;
    }//end changeDate
    }// end class

    Try Changing your namespace for java to ConvertDate2(This class should be in classpath) and replace
    <stringdate><xsl:variable name="stringDate" select="java:ConvertDate2.changeDate(ds_start_date)"/>
    </stringdate>
    with
    <stringdate><xsl:variable name="stringDate" select="java:changeDate(ds_start_date)"/>
    </stringdate>
    Make sure your query matches with ds_start_date correctly.

  • Is it possible to call Java routines from FMS?

    Say I have a game package, most of which
    are written in Java. I am thinking
    to leave the core logics in Java, but
    change the user interface into Flash,
    and serve it over FMS. Now is it
    possible to call Java routines from
    FMS?
    I'd appreciate any suggestions.

    Yes! You can use SOAP(or XML-RPC) to call Java routines.
    Relevant link:
    http://www.adobe.com/devnet/flashmediaserver/articles/fms_web_services_05.html
    Btw, does anyone know if there is XML-RPC package for
    FMS?

  • Call java code on submit anyaction on the BPEL form

    Dear All
    As you know in the BPEL form there is many action like Submit , Approve , Not Approve etc.. i want to call java code when i call any actions.
    Regards
    Wish79

    Hi friend,
    Maybe this is a sin, to ask a question about java on a .net forum but still going to try ;)
    As you said, this is a question about Java. I am afraid this is out of our support. You'd better ask in thier special forum. Like selenium.  Thanks for your understanding.
    Have a nice day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Looking for an idea to call action listner or other way to call java code

    Hi
    I'm building some project on JSF2
    I'm Looking for an idea to call action listner or other way to call java code from link(not commandlink)
    and i got a sign out button which i want to invalidate the session when its clicked...
    i cant do a redirect to a jsp... its a "special" link that does the log out , so i cant use the link for the session invalidation
    I dont want to use commandLink cause i need to put it into a form, and i don't to make my code uglier...
    any ideas?
    Im using JSF 2 (new to it)

    Under the constraints you have given the only thing I can think of is some kind of "pretty url" technique combined with JSF. Google can help you out. (Although that might be overkill for what you need.)
    Other than that I think you are looking at straight Java or JSP solutions that do not involve JSF.

  • Calling Java application(forms) from Oracle/Developer

    Hi
    How can i call java application by using Oracle/Developer 10g. Pl. name the methods that i can use.
    regards
    Touseef

    In Oracle a Java stored procedure is a program you write in Java to run in the server, exactly as a PL/SQL stored procedure. You invoke it directly with products like SQL*Plus, or indirectly with a trigger. You can access it from any Oracle Net client—OCI, precompiler, or JDBC.
    Oracle provides a fully-compliant implementation of the Java programming language and JVM. Oracle Database Java Developer's Guide explains how to write stored procedures in Java, how to access them from PL/SQL(or developer), and how to access PL/SQL functionality from Java. -> http://download-uk.oracle.com/docs/cd/B19306_01/java.102/b14187/chfive.htm#BABGCGBG

  • JNI Calling Java code when attaching to existing JVM

    I've got an Active/X that runs within IE, and also makes JNI calls (via the Invocation API) to Java code. Running within IE means there's already a JVM around, so I attach to it using JNI_GetCreatedJavaVMs
    This is fine. The problem is that I can't use the JNI findClass() to locate my Java classes, because I have no control over the classpath that the JVM is using to locate classes. The only solution I can think of so far is to either add my classes as part of the JVM, OR find out the classpath of the existing JVM (using System.getProperty("java.class.path") and copy my classes into that directory.
    Both solutions look ugly - anyone know of a cleaner way ?
    Mark.

    Toby, thanks for the reply.
    You're welcome.
    I notice from elsewhere on this forum, you're clearly a JNI expert.
    I've been known to work with it a little from time to time. =)
    My code has to work with JDK 1.1 so URLClassLoader is out. Writing my own classloader is fine, but how do I load it in the first place ? Is there something in JNI I've missed ?
    Possibly. Using DefineClass() you can load a class into the virtual machine, given it's byte-code. Now here's the tricky part. First, write your ClassLoader. It will be easiest if it doesn't rely on any other classes other than what is core to the JRE. Once you compile that classloader, you then need to include the bytecode as a resource in your executable/dll. Then, at runtime, you can load that resource, and use DefineClass to class-load it. Once you've class-loaded it, you can use NewObject, GetMethodID, CallXXXMethod, etc... to do the other class loading you need to do.
    Trust me, this really isn't as hard as it might sound.
    God bless,
    -Toby Reyelts
    As always, I recommend you check out the free, open-source JNI toolkit, Jace, at http://jace.reyelts.com/jace.

  • Calling java code from oracle apps form

    I've created my own java .class file and am attempting to call it from an oracle applications form. I am getting a runtime error while running the form, but I don't know what the error is because nothing is being reported to me.
    I've created the .java file in JDeveloper, compiled it into a .class file, deployed it to a .jar file, and placed it on the application server in a directory that the CLASSPATH can see it. I've added it to the archive parameter of the appsweb.cfg file and see that the .jar file is being downloaded when the JInitiator of Oracle Apps is started.
    I have also imported the .class file into the form via the Program -> Import Java Classes which resulted in PL/SQL package stubs created to call the .class methods.
    When I run the form, the java code is activated on a triggering event, PRE-INSERT. There is no java bean item in a block or on a canvas anywhere. I dont' think I need there to be since I am simply using the java code to perform actions during PRE-INSERT, not to display anything on the canvas.
    I have placed debug messages throughout my code and see that the error is occuring in the PL/SQL packaged stub at the line "JNI.GET_CLASS()" where the parameter to that call is the name of my class. I know it's erroring there because I am handling the "java_error" exception. I am displaying "ora_java.last_error" in the exception handling, but it is null.
    I am at a loss as to determine why I am having problems and how to display an error. Any suggestions? I'm happy to outline my steps and problem in more detail if I have missed something obvious.
    We are using Forms 6.0.8.21.3 with Oracle Apps 11.5.7.
    Shane.

    Shane,
    Don't loose the heart. You have come too close to end.
    The scenario you have mentioned is very unique and something which will fit more in the forms forum. So I think that was a sincere answer to help you and not a "pass the buck" card type game :)
    You are lucky that you got Tapash interested into this issue, otherwise you see there is no OAF component involved out here.
    I have an article promised to some of the guys but will follow this issue.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Calling Java code from Webdynpro Abap UI

    Hi All,
    Can anybody tell me, How to make calls to java code on a button click from webdynpro ABAP UI ?
    Thanks in Advance.
    Jenish .V. Joy

    Hi Jenish,
    As I am new to WebDynpro for ABAP I could not help you out exactly.But See this link which will help you to create applications in WebDynpro by using ABAP language.
    https://www.sdn.sap.com/irj/sdn/developerareas/abap?
    rid=/library/uuid/02e1fa45-0801-0010-10a0-f1cf47e8c943
    If you get any answer for your question let me know.
    Regards,
    Karthick K Eswaran

  • Is it possible to call C++ code from a HTML5 panel?

    I have thousands of lines of C++ code that I need to reuse inside my HTML5 panel for Illustrator. Is it possible to call my C++ functions from within my HTML5 panel? Some kind of wrapper maybe?

    Hi,
    A possible solution is to dispatch CSXS events from your HTML panel, and listen to those events in your C++ code and then execute your C++ code.
    Hui

  • Calling Java code inside JSP page and sending toString on object to Servlet

    Hi.
    I am trying to setup a way to make testing my application easier. Using a web-based method will work best. Here is what I am trying to accomplish:
    - Have a web page that will prompt the user to enter data, fill in text fields, make choices, etc. When done, they press the Submit button. I don't need to keep info between sessions. Just open browser, execute, view results, close browser, repeat.
    - I then want to take this data and use some Java Classes I have to create a Java object.
    - I then want to send the toString() results of this Java object to a known Java servlet. The result of the servlet's actions should be displayed as a response on the screen.
    This is what I currently have (Ignore the
    's - I don't know why they are showing up - its not important):
    Web page:
    <html>
    <head><title>TestGroup</title></head>
    <body>
    <form name=f method=post action=http://localhost:100/Servlet>
    Name: <br>
    Group: <input name=group type=text><br>
    <br>
    <input type=submit value=Submit>
    <input type=reset value=Reset>
    </form>
    </body>
    </html>The Java code in the JSP (where to put it?):
    <%
    Group g = new Group();
    g.setGroupName(request.getParameter("group"));
    String output = g.toString(); // I want this to go to the Servlet.
    %>But, now I am stuck as to how to piece these together. I have some JSP experience, but not quite like this.
    As I said, when the user presses the Submit button, I want to perform the Java code above, and have the results of the toString method sent to the Servlet, plus clear all other parameters (so they are not sent to the servlet).
    Does anyone have any advice/comments? I am open to alternative designs too, this is just the simplest one I could think of. If another JSP page is needed, that's fine too.
    Thanks.

    Hi.
    I am trying to setup a way to make testing my application easier. Using a web-based method will work best. Here is what I am trying to accomplish:
    - Have a web page that will prompt the user to enter data, fill in text fields, make choices, etc. When done, they press the Submit button. I don't need to keep info between sessions. Just open browser, execute, view results, close browser, repeat.
    - I then want to take this data and use some Java Classes I have to create a Java object.
    - I then want to send the toString() results of this Java object to a known Java servlet. The result of the servlet's actions should be displayed as a response on the screen.
    This is what I currently have (Ignore the
    's - I don't know why they are showing up - its not important):
    Web page:
    <html>
    <head><title>TestGroup</title></head>
    <body>
    <form name=f method=post action=http://localhost:100/Servlet>
    Name: <br>
    Group: <input name=group type=text><br>
    <br>
    <input type=submit value=Submit>
    <input type=reset value=Reset>
    </form>
    </body>
    </html>The Java code in the JSP (where to put it?):
    <%
    Group g = new Group();
    g.setGroupName(request.getParameter("group"));
    String output = g.toString(); // I want this to go to the Servlet.
    %>But, now I am stuck as to how to piece these together. I have some JSP experience, but not quite like this.
    As I said, when the user presses the Submit button, I want to perform the Java code above, and have the results of the toString method sent to the Servlet, plus clear all other parameters (so they are not sent to the servlet).
    Does anyone have any advice/comments? I am open to alternative designs too, this is just the simplest one I could think of. If another JSP page is needed, that's fine too.
    Thanks.

  • In Struts is it possible to use java code  in jsp?

    in Struts Tag Program in jsp pages is it efficient to use java code? Please explain?

    No issues.. you can use java code... in jsp struts
    based framework..
    SJYou can use Java code as scriptlets in any JSP, but that doesn't mean there are no issues.
    I would say it's a bad idea for the following reasons:
    (1) Scriptlet code is difficult to read when mingled with HTML
    (2) You can't unit test scriptlet code
    (3) It increases the chance that business logic will leak into pages where it doesn't belong.
    Better to use a well-proven tag library like JSTL or the Struts taglibs and keep all scriptlets out of your JSPs.
    %

  • Can MySQL triggers or storedprocedures(callbacks) call java code?

    I have to store the DB tables in the server side(i.e cache it) If someone updates the Data Base , The Data updates must be reflected in the cache in the server side. so how callbacks form the DB can be make to a java code in the server side.
    i am using Ms SQL and web logic server.
    or which DB and APP server can support it?

    Do the update request from the client via an java application(servlet,etc.) to an server application. The server application work with the db (via jdbc) and can so update the cache if any db update occurs.

  • Calling java class/procedure inside a trigger

    Hi all
    I want like to call a java procedure from a trigger.
    i know that i should load the class then write call specification and then call the java stored procedure.
    Before that what are the prerequisites ..
    Do i need to install java on my local machine?
    secondly for sample testing can you provide me a sample java code that will connect to my db and inserts some sample data into sample table
    regards
    raj

    Hi Here are the Details: I have the following
    Java File : Helloworld.java
    Class File : HelloWorld.class
    Location of Java and Class Files: C:\Program Files\Java\jdk1.6.0_13\
    Method : main(java.lang.String[])
    Helloworld.java
    class HelloWorldApp {
    public static void main(String[] args) {
    System.out.println("Hello World!"); // Display the string.
    loadjava -u HR/hr@ORCL C:\Program Files\Java\jdk1.6.0_13\HelloWorldApp.class ( From where should i run this command ?should i go to  windows--start--cmd  ? )
    CREATE OR REPLACE PROCEDURE sayhello ()
    AS LANGUAGE JAVA
    NAME 'HelloWorld.main(java.lang.String[])';
    CREATE OR REPLACE TRIGGER sal_trig
    AFTER UPDATE OF sal ON emp
    FOR EACH ROW
    CALL sayhello(); ------------------ ( where do i see the output when i call the procedure?)
    regards
    raj
    Edited by: raj_fresher on May 20, 2009 7:57 AM

  • Call Java from AS/400 DB2 Trigger

    I need to call a Java Program from an SQL Triger (is there anyway to do this?).
    I can call PGM files but my java program is a class file which I can call from:
    1- Command Line with JAVA or RUNJVA
    2- QSHELL with java
    3- SQLScript with CALL QSYS.QCMDEXC('java class(holamundo.PrintParametros) PARM(1 3)',0000000047.00000)
    I thought I could use the sentence CALL QSYS.QCMDEXC in an sql trigger but I couldn't.
    My trigger must be able to send parameters to my JAVA Program.
    I've set my environment variable CLASSPATH I need at *sys level in my AS/400 iSeries 270 with ADDENVVAR.
    Thank you for your time. I appreciate any information.
    Best regards.

    I thought... well if triggers are able to call PGM programs easily,
    then I can add a CL which calls my java program with 'java class
    (package1.ProgramX)' but it falied with the following message (NOTE
    that PGM program is RUNJVAPGM in library ADAM):
    ======================
    Message ID . . . . . . : CPF502B
    Date sent . . . . . . : 06/20/03 Time sent . . . . . . : 10:00:06
    Message . . . . : Error occurred in trigger program.
    Cause . . . . . : The trigger program which was called as the result of a
    database insert, update, delete, or read operation failed. See the previous
    messages in the job log to determine the error. The error code is 2 for
    trigger RUNJVAPGM in library ADAM type *SYS. This error code can be used to
    determine the trigger which caused the error, as follows:
    1 -- BEFORE INSERT trigger
    2 -- AFTER INSERT trigger
    3 -- BEFORE UPDATE trigger
    4 -- AFTER UPDATE trigger
    5 -- BEFORE DELETE trigger
    6 -- AFTER DELETE trigger
    More...
    ===============================
    Code is as follows
    *************** Beginning of data *************************************
    0001.00 PGM
    0002.00 MONMSG CPF502B
    0003.00 RUNJVA CLASS(holamundo.HolaMundo)
    0004.00 ENDPGM
    ****************** End of data ****************************************
    Any comments?

Maybe you are looking for

  • Macbook Air 2013 Doesn't recognise Toshiba Ext. Hard drive... Tips?

    Hi all, It's been a while since I last posted, but this one's got me tearing my hair out. My MBA 2013 doesnt seem to acknowledge the existence of my external hard drive, which I'd quite like to load some home movies onto. I plug it in, and it lights

  • Use of MPSS on Solaris 9 and Java 141_03 - not getting 4M pagesizes

    Hi all, Anyone know how to get MPSS actually using large page sizes in 1.4 / SunOS 5.9 ?? I have a 1.4.1_03-b02 JVM that is using the -XX:+UseMPSS option and using the LD_PRELOAD=/usr/lib/mpss.so.1 and MPSSHEAP=4M but when I use pmap -Fxs <PID> I alw

  • Exporting Playlist as text file

    Hi i want to Export my Playlist as text file listing, and send to a friend by email. In other words i want to send a list of all my albums in itunes in list form. (not all the songs) This should be simple enough, but i have wasted hours trying to do

  • How to insert a button on a page which changes the field value in a list

    Hi, I need to send a workflow email to the manager giving him an option to approve/reject the ongoing process. Now i want to make it such a way that, manager is redirected to some page, where he will see two button, Approve and Reject. On click of an

  • Running the script

    I have to run a script file with 150 sql commands to test the integrity of the database and output into an outfile.Is there any way to send the output results with sql syntax and its corresponding number.Thanks in advance for help.