APEX fails with Java stored procedure that creates a JDBC connection

Hello!
We are facing a strange problem since we have upgraded from Oracle 10g and Apache to Oracle 11g with Embedded Gateway.
Here is what we do:
** APEXX calls a PL/SQL package function "OPEN_CONNECTION" that wraps a Java stored procedure called "openConnection".*
FILE_READER_REMOTE_API.openConnection(user, password, host, port, service);
** The Java stored procedures "openConnection" opens a JDBC connection to an other database:*
public class FileReaderRemote {
private static Connection conn = null;
private static DefaultContext remoteContext = null;
public static void openConnection(String user, String password, String host, String port, String service) throws SQLException {
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
java.util.Properties props = new java.util.Properties();
props.put ("user", user);
props.put ("password", password);
//props.put ("database", "//" + host + ":" + port + "/" + service);
props.put ("database", host + ":" + port + ":" + service);
props.put("v$session.program", "FileReaderRemote2");
// Connect to the database
remoteContext = Oracle.getConnection("jdbc:oracle:thin:", props);
This procedure used to work fine before the upgrade, but now we see the following:
* It still works when called directly from TOAD or SQL*Plus, even under the user ANONYMOUS.
* When called from APEX and the target database is Oracle 11g, it still works.
* When called from APEX and the target database is Oracle 10g, it takes several minutes and we receive this error:
*"Socket read timed out"*
We have tested the following workaround:
We have created a database link to our own database and called the stored procedure through that database link.
FILE_READER_REMOTE_API.openConnection*@loopback*(user, password, host, port, service);
This works, but is not really an option.
I hope some one of you can explain this strange behaviour to me.
Best regards,
Matthias

You wrote
"Java stored procedures -- by definition - are stored in the 8i rdbms. !!"
From the Oracle8i Java Stored Procedures Developer's Guide
Release 8.1.5
A64686-01
"If you create Java class files on the client side, you can use loadjava to upload them into the RDBMS. Alternatively, you can upload Java source files and let the Aurora JVM compile them. In most cases, it is best to compile and debug programs on the client side, then upload the class files for final testing within the RDBMS"
This means that you can create shared classes that are used on both the client and server side. The source does not need to reside within the server (according to their documentation). Please also note the following from the Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 for using the getConnection() method on the server:
"If you connect to the database with the DriverManager.getConnection() method, then use the connect string jdbc:oracle:kprb:. For example:
DriverManager.getConnection("jdbc:oracle:kprb:");
Note that you could include a user name and password in the string, but because you are connecting from the server, they would be ignored."
So if you're coding a shared class that is to run on both the client and server side, you might do something like this:
Connection conn =
DriverManager.getConnection(
System.getProperty("oracle.server.version") == null
? "jdbc:oracle:thin:@hostname:1521:ORCL"
: "jdbc:oracle:kprb:"),
"youruserid","yourpassword");
As stated earlier, the userid and password are supposedly ignored for server connections retrieved in this manner. I haven't tried this yet, but it is documented by Oracle.
Regards,
Steve
null

Similar Messages

  • Problems with java stored procedure.

    I have a java stored procedure that uses a package called RmiJdbc
    which allows calling remote JDBC data sources from any java capable
    machine.
    I've loaded the RmiJdbc classes into oracle via the loadjava
    command and everything seems to come up valid.
    The stored procedure does a Class.forName() to get the driver
    registered, than attempts to connect to the remote RMI driver.
    The particular line it dies on is this (see the error below):
    c = DriverManager.getConnection("jdbc:rmi:" + rmiHost + "/" + url);
    A mangled version of this (minus the Oracle specific stuff) works
    from the command line correctly. Can somebody point me in a
    direction to figure out what's going on here?
    THanks,
    Eric
    Oracle9i Enterprise Edition Release 9.0.1.3.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.0.1.3.0 - Production
    ORACLE_HOME = /oracle/v901ee
    System name: HP-UX
    Node name: athena
    Release: B.11.00
    Version: A
    Machine: 9000/889
    Instance name: PASDB2
    Redo thread mounted by this instance: 1
    Oracle process number: 13
    Unix process pid: 7839, image: oracle@athena (TNS V1-V3)
    *** SESSION ID:(8.547) 2002-08-15 15:41:27.221
    java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
    java.lang.NullPointerException
    java.lang.NullPointerException
    at sun.rmi.server.LoaderHandler$LoaderKey.<init>(LoaderHandler.java)
    at sun.rmi.server.LoaderHandler.lookupLoader(LoaderHandler.java)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java)
    at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java)
    at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
    at java.io.ObjectInputStream.inputArray(ObjectInputStream.java)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
    at java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java)
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java)
    at java.io.ObjectInputStream.inputObject(ObjectInputStream.java)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java)
    at sun.rmi.registry.RegistryImpl_Stub.lookup
    at org.objectweb.rmijdbc.RJConnection.<init>(RJConnection:83)
    at org.objectweb.rmijdbc.Driver.connect(Driver:135)
    at java.sql.DriverManager.getConnection(DriverManager.java)
    at java.sql.DriverManager.getConnection(DriverManager.java)
    at TurnoverInfoPlusInterface.insertInterfaceRecords(TurnoverInfoPlusInterface:53)
    java.sql.SQLException: Error unmarshaling return; nested exception is:
    java.lang.NullPointerException
    at org.objectweb.rmijdbc.Driver.connect(Driver:140)
    at java.sql.DriverManager.getConnection(DriverManager.java)
    at java.sql.DriverManager.getConnection(DriverManager.java)
    at TurnoverInfoPlusInterface.insertInterfaceRecords(TurnoverInfoPlusInterface:53)

    More info...I'm also seeing "ORA-03113: end-of-file on communication channel". I checked the user trace file and didn't get much help...it indicated an "exception signal: 11" and core-dump type stuff that had no meaning to me.

  • Performance problem with java stored procedure

    hi,
    i developped a java class, then I stored it in Oracle 8.1.7.
    This class contains several import of other classes stored in the database.
    It works, but the execution perfomances are disappointing. It's very long. I guess, that's because of the great number of classes to load that are necessary for my class execution.
    I tried to increase the size of the java pool (I parameter 70 Mo in the java_pool_size parameter of the init.ora), but the performance is not much better.
    Has anyone an idea to increase the performance of this execution of my class ?
    In particular, is there a way to keep permanently in memory the java objects used by my class ?
    Thanks in advance
    bye
    [email protected]
    null

    before running Java, the database session needs to be Java enabled; this might be the reason why it is taking so long. If this is the case, you should see an improvement in subsequent calls, once a database session is Java enabled, other users can benefit from it.
    Kuassi
    I have some performance issue with java stored procedure. Hope some one will be able to help me out. I'm using java stored procedures in my application and basically these procedures are used to do some validation and form the XML message of the database tables. I have noticed that when I call the PL/SQL wrapper function, it is taking time to load the java class and once the class is loaded the execution is faster. Most of the time is spent for loading the class rather than executing the function. if I reduce the class load time, I can improve the performance drastically. Do any one of you know how to reduce the class load time. The following are the platform and oracle version.
    O/S: IBM AIX
    Oracle: 8.1.7

  • Stored Procedure that creates a trigger on new tables

    I am trying to create a stored procedure that creates a trigger on new tables whenever the table is created.  The procedure should receive the new project table's name, and then create a dml trigger on that procedure.  When the procedure
    is run, I get an error "Incorrect syntax near keyword 'TRIGGER.'"  This is how my Stored Procedure looks in SQL Management Studio.  Any suggestions?
    USE [RIDB_DynamicDesign]
    GO
    /****** Object: StoredProcedure [dbo].[sp_CreateTriggerMarkLatest] Script Date: 11/08/2014 16:43:20 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[sp_CreateTriggerMarkLatest] @ProjectTable nvarchar(128), @ItExists int OUTPUT
    AS
    DECLARE @SQL nvarchar(4000)
    DECLARE @MarkLatest nvarchar(30)
    DECLARE @LatTrue bit
    DECLARE @LatFalse bit
    SET @LatTrue = 'True'
    SET @LatFalse = 'False'
    SET @SQL = 'CREATE TRIGGER tr_MarkLatest ON ' + @ProjectTable + ' AFTER INSERT
    AS
    UPDATE ' + @ProjectTable + ' SET Latest = @LatFalse
    UPDATE ' + @ProjectTable + ' SET Latest = @LatTrue WHERE
    ID IN (SELECT ID FROM ' + @ProjectTable + ' p WHERE
    NOT EXISTS (SELECT 1 FROM ' + @ProjectTable + ' WHERE
    Name = p.Name AND Vers = p.Vers
    AND Date > p.Date))'
    EXEC sp_executesql @SQL, N'@ProjectTable nvarchar(128), @LatTrue bit, @LatFalse bit',
    @ProjectTable, @LatTrue, @LatFalse
    Gina

    First you have to debug the dynamic SQL string with a PRINT statement. I see some problems:
    CREATE PROCEDURE [dbo].[uspCreateTriggerMarkLatest] @ProjectTable nvarchar(128), @ItExists int OUTPUT
    AS BEGIN
    DECLARE @SQL nvarchar(4000)
    DECLARE @MarkLatest nvarchar(30)
    DECLARE @LatTrue bit
    DECLARE @LatFalse bit
    SET @LatTrue = 'True'
    SET @LatFalse = 'False'
    SET @SQL = 'CREATE TRIGGER tr_MarkLatest ON ' + @ProjectTable + ' AFTER INSERT
    AS
    UPDATE ' + @ProjectTable + ' SET Latest = @LatFalse
    UPDATE ' + @ProjectTable + ' SET Latest = @LatTrue WHERE
    ID IN (SELECT ID FROM ' + @ProjectTable + ' p WHERE
    NOT EXISTS (SELECT 1 FROM ' + @ProjectTable + ' WHERE
    Name = p.Name AND Vers = p.Vers
    AND Date > p.Date))'
    PRINT @SQL;
    -- EXEC sp_executesql @SQL, N'@ProjectTable nvarchar(128), @LatTrue bit, @LatFalse bit', @ProjectTable, @LatTrue, @LatFalse
    END
    GO
    DECLARE @ItExists int, @ProjectTable nvarchar(128) = N'TestTrigger';
    EXEC [dbo].[uspCreateTriggerMarkLatest] @ProjectTable, @ItExists OUTPUT
    CREATE TRIGGER tr_MarkLatest ON TestTrigger AFTER INSERT
    AS
    UPDATE TestTrigger SET Latest = @LatFalse
    UPDATE TestTrigger SET Latest = @LatTrue WHERE
    ID IN (SELECT ID FROM TestTrigger p WHERE
    NOT EXISTS (SELECT 1 FROM TestTrigger WHERE
    Name = p.Name AND Vers = p.Vers
    AND Date > p.Date))
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Deploy package with Java Stored Procedure without JDeveloper

    I have a set of Java Stored Procedures deployed as a package on a Oracle 8i server. Everything works fine in my development environment, and now I would like to deploy the same package in the customers runtime environment. Both environments are running Oracle 8i rel 2 on NT.
    Is there a simple way to use the JDeveloper .prf deployment profile without installing JDeveloper in the customers environment?
    If not, can I the get the .jar files and .sql scripts from JDeveloper to create the call specs and package bodys?
    I guess JDeveloper must have this information, and my idea was then to write a script using loadjava and SQL*Plus.
    Regards,
    Tom Bjerre

    you would not be able to take just the deployment profile and run it outside JDeveloper.
    You would be able to create archive of all java classes in the package using Deployment Wizard in JDeveloper.
    Then you can load the jar file using the utilities in 8i.
    JDeveloper does generate the SQL for CALL specs etc ., at the deployment time and it is printed in MEssage Viewer along with other information.
    Hope that info is useful for you
    raghu

  • How to write call specs for a java stored procedure that takes a nested obj

    Example Class :
    public class B {
    int number;
    String str;
    public class A {
    private B[] _childern;
    public B[] getChildern(){
    return _children
    public static void saveAll(A a) throws SQLException {
    B[] children = a.getChildern();
    for(int i=0; i<children.length; i++){
    saveChild(children);
    public static void saveChild(B ch)throws SQLException {
    // do something
    What would be the call specification for the method A.saveAll(A)? Your help will be apprecited.
    Thank you
    Ajmal

    In other words, How to pass a Java Object from a Java stored procedure to a Java client ???
    Hello,
    I don't know to deal with a Vector object that has been generated from a stored procedure.
    Should I create first in the JDBC client and pass it as argument to the procedure ?
    Thanks in advance. Here is an extract ...
    On the client side :
    <<
    Vector buffer = new Vector();
    CallableStatement call =
    con.prepareCall ("{call my_procedure_run (?, ?)}");
    call.registerOutParameter(2, java.sql.Types.JAVA_OBJECT );
    call.setString (1, "bla bla bla");
    call.setObject (2, buffer);
    call.execute ();
    buffer = (Vector)call.getObject (2);
    >On the Java stored procedure
    <<
    public class my_procedure
    public static void Run(String input_value, Vector buffer)
    // ??? Vector buffer = new Vector();
    try
    while ( true )
    buffer.addElement(...) ;
    catch(Exception ex) { }

  • Invoking Unix command with java stored procedure

    Hi,
    I have a perfectly working environment and now I am trying to replicate the same in another server. I have a java stored procedure which invokes the Unix command using java Runtime.exec() in my code named "run". I am sure that the code is called and the java class run is resolved in oracle as I could see that in dba_java_resolvers dictionary. But I am not sure whether the function in java is called or whether a exception is thrown. how to identify this? Could there be any thing to do with settings in oracle side? please help me.
    Thanks in advance,
    Marutha

    Hi,
    Do you get any output while running the code?
    I'm testing similar solution and if there are any errors or Oracle can't execute the program due to permissions or other issues the error information will be displayed. Also in the Java class itself you need to catch exceptions and print stack trace to standard output.
    declare
    x number;
    begin
    dbms_output.enable(1000000);
    dbms_java.set_output(1000000);
    x:=system_command.run_command('testconnect.sh');
    dbms_output.put_line('Returned value='||x);
    exception
    when others then dbms_output.put_line('Sql error='||substr(sqlerrm,1,250));
    end;
    <system_command.run_command> - replace with a call to your java stored procedure.

  • Help! Need oracle help with constructing stored procedure that return resultsets

    Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
    CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
    ResultSet rs = cs.executeQuery();
    Thats if you build your stored procedure something like this ...
    String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
    We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
    (p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
    is
    begin
    open p_cursor for
    select * from suppliers
    In which case the above mentioned sun code doesn't work.
    We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
    Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?

    Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
    CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
    ResultSet rs = cs.executeQuery();
    Thats if you build your stored procedure something like this ...
    String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
    We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
    (p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
    is
    begin
    open p_cursor for
    select * from suppliers
    In which case the above mentioned sun code doesn't work.
    We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
    Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?

  • Runtime.Exec() fails -- Through java stored procedure in Oracle8i

    HI,
    I HAVE A JAVA STORED PROCEDURE WHICH EXECUTES
    A HOST COMMAND USING Runtime.Exec().
    BUT IT IS NOT WORKING.
    RIGHTS FOR THE USER HAVE BEEN GIVEN USING
    Dbms_grant_persmission(). The database in on
    SUN SOLARIS. THE EXITVALUE OF THE RUNTIME.EXEC COMMAND IS 255(SEGMENTATION
    ERROR - CORE DUMPED).
    PLEASE LET ME KNOW WHERE THE PROBLEM LIES. THE FUNCTION IS WORKING WELL IF THE DATABASE IS ON NT PLATFORM BUT FAILS TO WORK WHEN I STORED THE PROCEDURE IN A DATABASE RUNNING ON SUN SOLARIS AND TRIED TO EXECUTE A SOLARIS COMMAND THROUGH THE PROCEDURE.
    Thanks for ur interest!
    with best regards,
    Mathan

    I have similar problem on HP-UX, I would appreciate if you
    somehow were able to solve it.
    Thanks
    Rahul Shah

  • Start with java stored procedure in SQLDeveloper

    Hi,
    i'm a newbe in writing PL/SQL stored procedures. Thats the reason to wont to write some java stored procedures for an ORACLE 10g. I'm using the SQLDeveloper. My Problem is: how can i start to write java stored procedures. Where have i to put them?
    Can somebody help me?
    10x
    cu nanostruct

    For Java Stored procedures you'll need to use JDeveloper. For SQL Developer, there is a viewlet and a tutorial on this page:
    http://www.oracle.com/technology/products/database/sql_developer/index.html
    Sue

  • Issue with a stored procedure that uses a sys refcursor to output dataset..

    Hi All:
    I create a stored procedure that uses an in out sys ref cursor:
    create or replace procedure FIRE_SALES_100_CALLS_REPORT
    ( p_cursor in out sys_refcursor)
    IS
    BEGIN
    --Insert into the temp table the records for the rep sales
    EXECUTE IMMEDIATE '
    INSERT INTO TMP_SALES_CNT_BY_USER
    TOTALPRODUCTSSOLD,
    NUMBEROFCALLS,
    SALESPER100CALLS,
    SERVICEORDERNUM,
    PRODUCT,
    LOGIN,
    FST_NAME,
    LAST_NAME,
    NAME,
    POSITIONHELD,
    CURRENTPARPARTYID,
    QUERY_DATE,
    CREATED_BY
    SELECT e.TotalProductsSold,
    e.NumberOfCalls,
    ((e.TotalProductsSold/e.NumberOfCalls)*100) AS SalesPer100Calls,
    e.ServiceOrderNum,
    e.Product,
    e.login,
    e.fst_name,
    e.last_name,
    e.name,
    e.PositionHeld,
    e.CurrentParPartyID,
    e.query_date,
    e.created_by
    FROM (
    SELECT COUNT(o.order_num) over ( partition by u.login
    order by u.login) AS TotalProductsSold,
    SUM(NVL(x.n_inbound,1) + NVL(x.n_outbound,1)) over (partition by u.login
    order by u.login) AS NumberOfCalls,
    o.order_num AS ServiceOrderNum,
    pi.name as Product,
    u.login,
    c.fst_name,
    c.last_name,
    postn.name,
    c.pr_held_postn_id as PositionHeld,
    p.par_party_id as CurrentParPartyID,
    NVL(x.query_date,NVL(o.last_upd, null)) AS query_date,
    o.created_by
    FROM firestg.SEB_S_order o
    INNER join firestg.seb_s_order_item oi ON o.row_id = oi.order_id
    INNER join firestg.seb_s_prod_int pi ON oi.prod_id = pi.row_id
    INNER join firestg.SEB_s_contact c on c.Row_Id = o.created_by
    INNER join firestg.SEB_s_user u on u.row_id = o.created_By
    INNER join firestg.SEB_s_party p on p.row_id = c.pr_held_postn_id
    INNER join firestg.SEB_s_postn postn on postn.row_id = c.pr_held_postn_id
    LEFT OUTER JOIN (
    SELECT taw.QUERY_DATE,
    vaw.n_inbound,
    vaw.n_outbound,
    oaw.object_name, oaw.object_id
    FROM GEN_T_AGENT_WEEK taw
    INNER JOIN GEN_V_AGENT_WEEK vaw ON taw.time_key = vaw.time_key
    INNER JOIN GEN_O_AGENT_WEEK oaw ON oaw.object_id = vaw.object_id) x
    ON u.cti_acd_userid = x.object_name
    WHERE NVL(x.query_date,NVL(o.last_upd, null)) BETWEEN (TRUNC (next_day (sysdate, ''SUN''))-14)
    AND (TRUNC (next_day (sysdate, ''SUN''))-8)
    AND o.status_cd IN (''Complete''))e';
    --Lookup the first level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_1ST, LOGIN_1ST,FST_NAME_1ST,LST_NAME_1ST,TITLE_1ST) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.currentparpartyid)
    WHERE CurrentParPartyID IS NOT NULL';
    --Lookup the second level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_2ND, LOGIN_2ND,FST_NAME_2ND,LST_NAME_2ND,TITLE_2ND) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_1ST)
    WHERE a.ParPartyID_1ST IS NOT NULL';
    --Lookup the third level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_3RD, LOGIN_3RD,FST_NAME_3RD,LST_NAME_3RD,TITLE_3RD) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_2ND)
    WHERE a.ParPartyID_2ND IS NOT NULL';
    --Lookup the fourth level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_4TH, LOGIN_4TH,FST_NAME_4TH,LST_NAME_4TH,TITLE_4TH) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_3RD)
    WHERE a.ParPartyID_3RD IS NOT NULL';
    --Lookup the fifth level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_5TH, LOGIN_5TH,FST_NAME_5TH,LST_NAME_5TH,TITLE_5TH) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_4TH)
    WHERE a.ParPartyID_4TH IS NOT NULL';
    -- If there was no 1st place then the rep is a VP
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.last_name || '', '' || a.fst_name,
    a.vp_login = a.login
    WHERE a.login_1st IS NULL';
    --If there is no second place then the rep has a VP and is a Director
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.vp_login = a.login_1st,
    a.director = a.last_name || '', '' || a.fst_name,
    a.director_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NULL';
    --IF there is no third place then the rep has a VP, Director & is a Manager
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.vp_login = a.login_2ND,
    a.director = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.director_login = a.login_1st,
    a.manager = a.last_name || '', '' || a.fst_name,
    a.manager_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NULL';
    --If there is no fourth place then the rep has a VP, Dir, Manager, and is a Supervisor
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.vp_login = a.login_3RD,
    a.director = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.director_login = a.login_2ND,
    a.manager = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.manager_login = a.login_1st,
    a.supervisor = a.last_name || '', '' || a.fst_name,
    a.supervisor_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NULL';
    --If there is no fifth plance then the rep has a VP, Dir, Mgr, Supervisor, and is a Team Lead
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_4TH || '', '' || a.fst_name_4TH,
    a.vp_login = a.login_4TH,
    a.director = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.director_login = a.login_3RD,
    a.manager = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.manager_login = a.login_2ND,
    a.supervisor = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.supervisor_login = a.login_1st,
    a.teamlead = a.last_name || '', '' || a.fst_name,
    a.teamlead_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NOT NULL
    AND a.login_5th IS NULL';
    --If there is a fifth place then the rep has a VP, Dir, Mgr, Supervisor, Team Lead and is a rep
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_5TH || '', '' || a.fst_name_5TH,
    a.vp_login = a.login_5TH,
    a.director = a.lst_name_4TH || '', '' || a.fst_name_4TH,
    a.director_login = a.login_4TH,
    a.manager = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.manager_login = a.login_3RD,
    a.supervisor = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.supervisor_login = a.login_2ND,
    a.teamlead = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.teamlead_login = a.login_1st
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NOT NULL
    AND a.login_5th IS NOT NULL';
    open p_cursor for
    SELECT tsc.vp,
    tsc.director,
    tsc.manager,
    tsc.supervisor,
    tsc.teamlead,
    (tsc.last_name || ', ' || tsc.fst_name) AS Rep,
    tsc.product,
    tsc.totalproductssold,
    tsc.numberofcalls,
    tsc.salesper100calls
    FROM TMP_SALES_CNT_BY_USER tsc;
    END FIRE_SALES_100_CALLS_REPORT;
    The table I use is a Global temp table.
    This runs just fine in oracle but when I try to build a data foundation in Business Objects I get the error that says you cannot insert/update/delete in a READ ONLY Transaction.
    I really need some advice on what to do since I really dont have access to a scheduled script and table that would store my data ahead of time.

    Well, AFAIK, BO is a reporting tool, so it si read-only by nature. I do not know if it possible to "tell" BO table is GTT and it is OK to write to it. You need to post this in BO forum.
    SY.

  • Java Stored Procedure / Server Side / Client Side / connection

    Hi,
    I would like to know if we can know at the runtime with a JDBC api if the stored procedure is running in client side or in server side ?
    THANKS

    You wrote
    "Java stored procedures -- by definition - are stored in the 8i rdbms. !!"
    From the Oracle8i Java Stored Procedures Developer's Guide
    Release 8.1.5
    A64686-01
    "If you create Java class files on the client side, you can use loadjava to upload them into the RDBMS. Alternatively, you can upload Java source files and let the Aurora JVM compile them. In most cases, it is best to compile and debug programs on the client side, then upload the class files for final testing within the RDBMS"
    This means that you can create shared classes that are used on both the client and server side. The source does not need to reside within the server (according to their documentation). Please also note the following from the Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 for using the getConnection() method on the server:
    "If you connect to the database with the DriverManager.getConnection() method, then use the connect string jdbc:oracle:kprb:. For example:
    DriverManager.getConnection("jdbc:oracle:kprb:");
    Note that you could include a user name and password in the string, but because you are connecting from the server, they would be ignored."
    So if you're coding a shared class that is to run on both the client and server side, you might do something like this:
    Connection conn =
    DriverManager.getConnection(
    System.getProperty("oracle.server.version") == null
    ? "jdbc:oracle:thin:@hostname:1521:ORCL"
    : "jdbc:oracle:kprb:"),
    "youruserid","yourpassword");
    As stated earlier, the userid and password are supposedly ignored for server connections retrieved in this manner. I haven't tried this yet, but it is documented by Oracle.
    Regards,
    Steve
    null

  • Trying to use Java Stored Procedure to create  directories

    Hello, I have the followqing simple Java code I am using to run OS commands from PL SQL. When I call my function, it does not create the directory, but it does say completed successfully. Here is the code and the call I am using:
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED Command
    AS
    import java.io.*;
    import java.util.*;
    public class Command{
    public static void run(String cmdText)
    throws IOException, InterruptedException
    try {
    int rtn;
    Runtime rt = Runtime.getRuntime();
    Process prcs = rt.exec(cmdText);
    rtn = prcs.waitFor();
    catch ( Throwable ex ) {
    ex.printStackTrace();
    CREATE OR REPLACE FUNCTION runoscommand(cmd IN VARCHAR2) RETURN NUMBER
    AS LANGUAGE JAVA
    NAME 'Command.run(java.lang.String) return int';
    DECLARE
    v_directory VARCHAR2(100):= 'C:\SYSTEM Interface\PL\files\';
    v_rtn VARCHAR2(2000);
    v_oscmd VARCHAR2(420);
    BEGIN
                v_oscmd := 'mkdir "' || v_directory || '"';
                dbms_output.put_line(v_oscmd);
                SELECT runoscommand(v_oscmd) INTO v_rtn FROM DUAL;
                dbms_output.put_line(v_rtn);
    END;
    /Any ides on why this is not working? Any better suggestions for doing this? I need to be able to create directories from with in a PL SQL Stored Procedure. Thank you

    Simple dude, you java code returns void, whereas your function returns an int. Change the java code to return an int (and return an int)

  • Using Java Resources with Java Stored Procedures

    Hi folks,
    Hope someone can help out with this one.
    I have a java source file called PdfFormExtractor.sql. In that file I have a definition similar to.
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "PdfFormExtractor" as
    import com.adobe.pdf.FormDataFormat;
    import com.adobe.pdf.FormType;
    import com.adobe.pdf.PDFDocument;
    import com.adobe.pdf.PDFFactory;
    etc, etc.
    };I have loaded a number of Java jar files into the DB with the following command:
       CALL loadjava -v -s -r -u db_user_name/db_password@SID -jarasresource name_of_jar_file.jarMy PdfFormExtractor class compiles with errors as it does not seem to detect the class files located in the jar files which located in the schema.
    I have used the following query and determined that the JAR files are valid and present in the schema.
    SELECT object_name, object_type, status, timestamp
      FROM user_objects
    WHERE (object_name NOT LIKE 'SYS_%'
             AND object_name NOT LIKE 'CREATE$%'
             AND object_name NOT LIKE 'JAVA$%'
             AND object_name NOT LIKE 'LOADLOB%')
       AND object_type LIKE 'JAVA %'
    ORDER BY object_type, object_name;One solution appears to be to omit the "-jarasresource". This appears to cause loadjava to unpack the jar files. Unfortunately this means that you must drop any java objects from the same path as which they were created. Ideally I'd like to just load the java files and leave them as resources.
    My question then is how do I get my source code to recognize that the files are in the schema. I thought this would be picked up when I do @PdfFormExtractor.sql from a sqlplus prompt (assuming the jars have been loaded and unpacked in the schema)
    because I specified RESOLVE in the source definition
    If anyone has any ideas they are most welcome as I've been stuck on this for the past couple of hours.
    Regards
    Kris
    -- http://kristianjones.blogspot.com

    I advise you to post this thread on the Java forum JDeveloper and ADF
    Regards.

  • Transformation to WORD from XSLT with java stored procedure - PROBLEM

    Hi all,
    I'm building a java function for transformation of xml document through .xslt scheme to WORD. I use xalan.
    Now, everything works fine if I run the java function on the client VM
    But on the server where the classes needed for the transformation are loaded, it crashes with a strange exception
    nulljava.lang.NullPointerException
    Now I've located the problem, and it occurs in this line in the java code:
    transformer.transform( new StreamSource(xmlFile),  new StreamResult(osIzlez));
    (where xmlFile is the source for the transformation, and the transformer is configured with the proper .xslt scheme, osIzlez points to a bytearraystream of a blob in the database where the .doc file is going to be generated and loaded)
    I also found out that the NullPointerException occurs because the transformer is actually null on the server (although it's configured with the .xstl scheme and should not be null ! ), but on the client it's never null!
    What could be the problem, does anyone have an IDEA?
    Edited by: Daniel Kiprijanovski on 17.9.2009 03:07

    OK, i found out that there's a reported bug about that exception on the java VM. I found a way arround it however.
    Thanks,
    Daniel K.

Maybe you are looking for

  • APEX Report Data Download in Excel and PDF format

    Hi, Can someone please guide me how to download APEX report data in Excel and PDF format.I know this is possible through BI Publisher but that is extra Licence cost for client so i don't want to use that option. Thanks in advance. Regards Prabhat Mis

  • How to add item in column header

    How can i add an messageStyled item(or any item) in column header? if so how can i do this

  • Line item restriction after billing in sales order ?

    Hi All i am new to this forum and this is my first question going to put up After doing the billing , i am able to add another line item in the sales order via va02 , so i want know how can i restrict to add line item after completing whole cycle in

  • I'm not able to get my mac os 10.6.8 to print to a Savin C2525, any suggestions?

    I'm not able to get my Mac OS 10.6.8 to print to a Savin C2525. I've loaded the drivers and after checking for updates and tried to add the printer. The 1st time I tried, it started printing and I could see the file name on the first page, after it p

  • An error occured while trying to access this service

    I signed up to convert PDF to word, paid my money and have spent over an HOUR trying to get it to work and reading forums.  I have tried EVERYTHING listed and just want to convert.  I get this message on the program: An error occured while trying to