Refcursor not returning rows when called from non SQL*Plus IDE or other

Hi all,
I have a very weird problem.
We have recently performed a minor upgrade to our oracle database and are now using:
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE    10.2.0.5.0      Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
5 rows selected.We have a crystal report selecting data from a refcursor returned by a stored procedure.
The stored procedure updates data when called as well as returning the refcursor in question.
Observe the following test scenario executed in SQL*Plus:
SQL> create table testtab (teststr varchar2(100));
Table created.
Elapsed: 00:00:00.00
SQL> insert into testtab values ('X');
1 row created.
Elapsed: 00:00:00.00
SQL> create or replace procedure testtabproc (p_listcur in out sys_refcursor)
  2  as
  3  begin
  4 
  5     open p_listcur for
  6        select *
  7          from testtab
  8         where teststr = 'X';
  9 
10 
11     update testtab
12        set teststr = 'Y';
13 
14        commit;
15 
16  end;
17  /
Procedure created.
Elapsed: 00:00:00.00
SQL> declare
  2 
  3  v_list_cur sys_refcursor;
  4 
  5  type t_out_rec is record (teststr varchar2(100) );
  6 
  7 
  8 
  9  v_out_rec t_out_rec;
10 
11  v_rec_count   number := 0;
12  v_count_limit number := 10000;
13 
14  begin
15 
16  dbms_output.put_line('about to call proc');
17
18  testtabproc(v_list_cur);
19 
20  dbms_output.put_line('about to fetch records');
21 
22  fetch v_list_cur into v_out_rec;
23  while v_list_cur%found loop
24     v_rec_count := v_rec_count + 1;
25     if v_rec_count <= v_count_limit then
26       dbms_output.put_line(v_out_rec.teststr);
27     end if;
28  fetch v_list_cur into v_out_rec;
29  end loop;
30  dbms_output.put_line('complete. selected '||v_rec_count||' records.');
31 
32 
33  end;
34  /
about to call proc                                                                                                                 
about to fetch records                                                                                                             
X                                                                                                                                  
complete. selected 1 records.                                                                                                      
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> select * from testtab;
TESTSTR
Y
1 row selected.
Elapsed: 00:00:00.00
SQL> as you can see, the cursor returns data and the table is updated.
now, our problem is with crystal and also when I use the same test case via another IDE like TOAD.
No data is returned from the list but the table is still updated.
We suspect that something is happening that is causing the table to be updated before the refcursor is opened, or at least before the predicates are applied.
has anyone else encountered this problem before?

Tubby wrote:
WhiteHat wrote:
nope - it works from sqlplus itermitantly (i.e. we always get the debug output but the cursor only sometimes fetches the rows).
it is almost as if the commit is being executed before the cursor is opened.
I still havn't been able to reproduce it except with the actual scenario that I am working with...Is the code you are dealing with exactly the same as the skeleton you've posted in your original post? Do you perhaps have a generic exception catcher in there somewhere (perhaps catching and hiding an ORA-01555) when the cursor is being fetched?
Not that i expect it to make any difference, but i'm curious as to why you've declared your cursor as IN / OUT ?
p_listcur in out sys_refcursor
the code structure in the real example is almost identical to that test case I produced - the exception handler is only catering for no_data_found, all other errors should be raised as normal.
edit: sorry I forgot to add - it's in/out because apparently that's what crystal reports needs in order to use the refcursor..... I'm not a crystal guy so I can't be any more specific than that sorry......
Edited by: WhiteHat on Oct 11, 2010 9:34 AM

Similar Messages

  • Java works stand alone does not when called from PL/SQL

    I have this piece of code, which works as a standalone program: It takes in the en_var and returns a path.
    But it wont work when called from a store procedure the line of code p = rt.exec("echo "+envar); returns a path as a standalone program returns null when called from a Oracle store procedure.
    Thanks for any help just going around and round in circles.
    import java.util.*;
    class translate
    public static String translatePath(String envar)
    Runtime rt = Runtime.getRuntime();
    int bufSize = 4096;
    byte buffer[] = new byte[bufSize];
    String path = null;
    Process p = null;
    String os = null;
    String name = null;
    String home = null;
    String dir = null;
    SecurityManager sm = null;
    int len = 0;
    try
    System.out.println("Calling echo "+envar);
    os = System.getProperty("os.name");
    name = System.getProperty("user.name");
    home = System.getProperty("user.home");
    dir = System.getProperty("user.dir");
    sm = System.getSecurityManager();
    p = rt.exec("echo "+envar);
    BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
    while ((len = bis.read(buffer, 0, bufSize)) != -1)
    System.out.write(buffer, 0, len);
    path = new String(buffer);
    //p.waitFor();
    bis.close();
    return path;
    catch(Exception e)
    System.out.println("Exception "+e);
    return "ProcessProblem";
    //path = "/rims/live/log";

    Still cant get it to work, it doesnt fall over anymore, but when I input $PATH, it will output $PATH instead of the path for $PATH i.e /rims/live: What does your program output please:
    Here is my code:
    import java.io.*;
    import java.util.*;
    class translate
         public static String translatePath(String envar)
              Runtime rt = Runtime.getRuntime();
              Process p = null;
              String echoOutput = null;
              int len = 0;
              try
                   System.out.println("Calling echo "+envar);
                   p = rt.exec(new String[]{"/bin/echo",envar});
                   InputStreamReader isr = new InputStreamReader(p.getInputStream());
                   BufferedReader br = new BufferedReader(isr);
                   echoOutput = br.readLine();
                   br.close();
                   isr.close();
                   return echoOutput;
              catch(Exception e)
                   System.out.println("Exception "+e);
                   return "ProcessProblem";
              //path = "/rims/live/log";
    Thanks for all your help so far.
    Tony

  • Why won't my Razr Maxx ring when called from my home phone or the other cell phone (I-phone) on my Verizon account?

    Why won't my Razr Maxx ring when called from my home phone or the other cell phone (I-phone) on my Verizon account?

    Hi Ruth:
    Thanks for reaching out to me about this issue.
    This has been happening since I got the phone a couple of years ago.
    I did not realize that my home land line and my wife's cell phone
    always go straight to voice mail until my wife pointed it out to me
    several months ago.  Is there a setting I can adjust?
    Yes, I can make calls to our home land line and to her cell phone
    without being diverted to voice mail.
    Any advice you might have would be most welcome.
    Thanks.
    Greg Bostwick
    On 12/22/14, Verizon Wireless Customer Support

  • Advanced table:not able to view more than 10 rows when called from workflow

    Hi everyone,
    I'm calling a page that contains advanced table and its controller class from two places.
    First one is from a inquiry form, when this page is called it works fine. when there are more than 10 rows, first 10 are shown on page render and when we click on Next link, other rows are shown. This is becuase I have given the records displayed property on adavanced table = 10. I'm fine till here.
    Second one is I'm calling this page again from a workflow notificaiton. There is a link called view more details on the workflow notification , click of this link will open the page with 10 records displayed. But when user tries to click on Next it doesn't work. It just doesn't refresh.
    Its very wierd,. not able to understand what could be wrong when calling from wf notificiton. Its the same page and conroller code used in both the places.
    Please help me!!
    Thanks
    Sunny

    Thanks for your response Kristofer. You are correct, there was a difference in the parameters and the issue is resolved now.

  • Stored Procedure Does Not Run Properly When Called From Portlet

    We have a simple Java portlet that calls a PL/SQL stored procedure which we wrote. The stored procedure sends a large number of emails to users in our corporation using the "utl_smtp" package. The stored procedure returns a count of the emails back to the Java portlet when it's finished. This number is displayed in the portlet.
    Our problem:
    The stored procedure functions as expected when run from a PL/SQL block in SQL*Plus, and the Java portlet calls the procedure properly when sending out a smaller number of emails (Less than 200 usually). When we get into a higher number of emails the procedure hangs when called from the portlet, but it STILL functions properly from SQL*Plus. It does not return the number of emails sent
    and the Java portlet is unable to return a SQLException. Also, we have noticed that emails are sent at a much slower pace from the stored procedure when it's called from the portlet.

    Any Ideas?

  • I found out issue distinct clause in query ,refcursor not returning rows

    URGENT
    hi the following procedure returns records  but when i add  distinct clause to (open v_refcursor for select )
    i.e   open v_refcursor for select distinct column1,column2   .......... in the procedure the procedure is not returning records. please help what is the issue here?
    CREATE OR REPLACE procedure proc_shared_report3 (in_cust_id varchar2,in_user_array user_tab , in_acct_array acct_tab,in_report_pvlg_hier varchar2,in_fmt_pvlg_hier varchar2,v_refcursor OUT sys_refcursor)
    is
    BEGIN
    if  in_acct_array.count>0 and in_fmt_pvlg_hier is not null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null  then
    dbms_output.put_line('all are not null');
    *open v_refcursor for  select usr_id* from vw_get_user_profile where usr_id in (
            SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2  WHERE 
            up1.usr_id=up2.usr_id and
            up1.product_hierarchy=in_report_pvlg_hier  and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND up1.usr_id in (select usr_id from vw_get_user_for_customer where
            cust_id=in_cust_id)
            and up1.usr_id Member Of in_user_array) AND acct_nb Member of in_acct_array);
    /* if account list is null and rest all  not  null */
    elsif (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is not  null  and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null  then
    dbms_output.put_line('acc is null and rest are not null');
    *open v_refcursor for select usr_id,usr_type_cd* from vw_get_user_profile where usr_id in(SELECT  distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2  WHERE 
              up1.usr_id=up2.usr_id and
              up1.product_hierarchy=in_report_pvlg_hier and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND   up1.usr_id in (select usr_id from vw_get_user_for_customer where
              cust_id=in_cust_id)
              and up1.usr_id Member Of in_user_array);
    /* if account list is null and format pvlg hierarchy is null */
    elsif  (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null
    then
    dbms_output.put_line('acc is null and format is null null');
    *open v_refcursor for select usr_id,tmzon_cd* from vw_get_user_profile where usr_id in (
      (SELECT  distinct usr_id FROM vw_get_user_privileges  WHERE  product_hierarchy=in_report_pvlg_hier  AND   usr_id in (select usr_id from vw_get_user_for_customer where
       cust_id=in_cust_id)
       and usr_id Member Of in_user_array))  ;
    /* if account list is not null and format pvlg hierarchy is  null */
    else  -- If i get only one privilege and all other inputs then 
    dbms_output.put_line('acc list is not null and format pvlg is null');
    *open v_refcursor for select usr_id,prod_shrt_nm* from vw_get_user_profile where usr_id in (
         SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT  distinct usr_id FROM vw_get_user_privileges  WHERE 
         product_hierarchy=in_report_pvlg_hier  AND   usr_id in (select usr_id from vw_get_user_for_customer where
         cust_id=in_cust_id) and usr_id Member Of in_user_array ) AND acct_nb Member of in_acct_array);
    END IF;
    END proc_shared_report3;
    /Edited by: raj_fresher on Aug 12, 2009 8:50 AM
    Edited by: raj_fresher on Aug 12, 2009 1:40 PM

    its like this ...... ?
    You have to understand that without any testdata/ a reproducable testcase, all I can do is asking you to test some alternatives, I'm just guessing things from what I can make of your example, and hope you'll repost back any differences in a clear and concisive way.
    What I didn't understand is why you're not just joining your tables/views instead of using inner queries.
    Unfortunatly you're not providing any feedback on that, on the other hand you've narrowed down your problem to a specific part of your query? But you're not sharing why/what makes you decide to take that turn.
    But: you're still using inner queries in your reply.
    So, sorry, I cannot proceed/say anything useful unless you answer my previous post.
    Because, there are still many other questions/doubts: I don't understand why you're not aliasing your columns properly, for example.
    I don't know why you've suddenly switched to VW_GET_USER_cust_sa?
    I don't know if you've tried the straight join instead of nesting queries?
    And if you did, what's the problem?
    Please read and understand this, so you'll get your answers by the speed of light the next time you've got a question or problem:
    http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
    And don't refrain from using that tag ;)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Java class files works on middle tier but chokes when called from pl/sql

    Hi,
    I have 2 class files WorkOrder and xxWorkOrder. xxWorkOrder creates an instance of WorkOrder. Both classes are under the /classes directory. Both compile fine and I have used loadjava to upload/resolve both in the database. I can see them as valid under the user_objects table. I created a function using Pl/sql which calls a method in xxWorkOrder. If I remove the line in xxWorkOrder where it creates an instance of WorkOrder, the pl/sql function works fine via sql plus. If I add the line in, it gives me ORA-29532: Java call terminated by uncaught Java exception: java.lang.ExceptionInInitializerError if i run my test again I get a No classdef found error.
    If i run the xxWorkOrder class file directly from the server using java, the code works fine with the instantiation of WorkOrder within it.
    I'm not sure which step I am missing ? For some reason when the pl/sql function calls the java method in xxWorkOrder and it sees the line where the instance of WorkOrder is created, it chokes.
    Please help!
    Preeti

    ExceptionInInitializerError means that whatever is being done at the time it occurs is trying to use some class for the first time so that an attempt to initialize that class is occurring and failing. Such a failure typically means that there is code in a static initializer, such as the foo(); in
    static SomeType someVarName = foo();
    or just any thing within
    static { ... }
    in the class being initialized which signals an uncaught exception. It's impossible to say why this would be happening in your particular case without seeing the code. Depending on the release you are using there may be more information (such as a backtrace of the original error) in the .trc file. An example of what I am describing in your case would be if the constructor for WorkOrder invoked a method on some class N, where N hadn't previously been used and where N contained
    static Class loser = Class.forName('no/such/Class');
    In this (admittedly goofy) case you might expect to see in the .trc file a backtrace for the ExceptionInInitializer error with a sub backtrace identified with "Caused by" that starts with a NoClassDefFound exception or the like. This might work outside the server if "no/such/Class" was present there but had not been loaded into the database.

  • URLConnection returns NULL when called from within a weblogic servlet

    The following code snippet works when executed outside of weblogic, but does
    not work from within a weblogic servlet instance.
    URL u = new URL("http://" + ipString + newString.toString());
    URLConnection uc = u.openConnection();
    BufferedReader in = new BufferedReader (new InputStreamReader(uc.getInputStream()));
    String response = "", response2 = "";
    while(response2 != null)
         response = ((response2 = in.readLine()) == null) ? response : response + response2;
    The response is quite big. When this code is executed from within a weblogic servlet instance,
    in.readLine always returns a null right away. Yet a TCP/IP trace shows that the packets are coming
    back to my NT machine.
    Other info:
    Inside of weblogic:
    u's handler is of type weblogic.net.http.Hanlder
    uc is of type weblogic.net.http.HttpURLConnection
    Outside of weblogic:
    u's handler is of type sun.net.www.protocol.http.Handler
    uc is of type sun.new.www.protocol.http.HttpURLConnection
    Weblogic V4.51. Running on NT.
    Attempted the following to no avail:
    1. installing sp11
    2. changing the security to permission java.security.AllPermission;
    3. adding the following calls : uc.setRequestProperty("Content-Type", "text/xml");          
              uc.setDoInput(true);
              uc.setDoOutput(true);
    4. Started playing around with modifying the java.protocol.handler.pkgs system property,
    but I shouldn't have to do this.
    Any help would be appreciated.

    There are some problems with the WL implementations of certain protocols.
    WL hides the Sun implementations when you are in the WebLogic server. Here
    is an a solution that was posted to a similar problem:
    Https is an add-in so to speak. Try this before you create your url:
    System.setProperty ("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol");
    // add the default security provider (again, in JSSE1.0.1)
    int iap = java.security.Security.addProvider(new
    com.sun.net.ssl.internal.ssl.Provider() );
    dennisNote how the code overides the WL setting which overode the Sun setting.
    Cameron Purdy
    [email protected]
    http://www.tangosol.com
    WebLogic Consulting Available
    "Brian Howell" <[email protected]> wrote in message
    news:[email protected]...
    >
    The following code snippet works when executed outside of weblogic, butdoes
    not work from within a weblogic servlet instance.
    URL u = new URL("http://" + ipString + newString.toString());
    URLConnection uc = u.openConnection();
    BufferedReader in = new BufferedReader (newInputStreamReader(uc.getInputStream()));
    >
    String response = "", response2 = "";
    while(response2 != null)
    response = ((response2 = in.readLine()) == null) ? response : response +response2;
    The response is quite big. When this code is executed from within aweblogic servlet instance,
    in.readLine always returns a null right away. Yet a TCP/IP trace showsthat the packets are coming
    back to my NT machine.
    Other info:
    Inside of weblogic:
    u's handler is of type weblogic.net.http.Hanlder
    uc is of type weblogic.net.http.HttpURLConnection
    Outside of weblogic:
    u's handler is of type sun.net.www.protocol.http.Handler
    uc is of type sun.new.www.protocol.http.HttpURLConnection
    Weblogic V4.51. Running on NT.
    Attempted the following to no avail:
    1. installing sp11
    2. changing the security to permission java.security.AllPermission;
    3. adding the following calls : uc.setRequestProperty("Content-Type","text/xml");
    uc.setDoInput(true);
    uc.setDoOutput(true);
    4. Started playing around with modifying the java.protocol.handler.pkgssystem property,
    but I shouldn't have to do this.
    Any help would be appreciated.

  • Report does not come up when called from Forms

    I have installed Oracle 9i database and dveloper suit on my pc. When I run reports from forms, the report does not come up. I have Adobe Acrobat reader 6. The report does get created, I can see it in the cache directory.
    It created an error file, I am posting the begining of this file here.
    Please help.
    Thanking you in advance.
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x65553878
    Function name=Java_oracle_reports_engine_EngineImpl_CGetEnv
    Library=C:\orahome1\bin\rw90.dll
    Current Java thread:
         at oracle.reports.engine.EngineImpl.CGetEnv(Native Method)
         at oracle.reports.engine.EngineImpl.getEnvs(EngineImpl.java:453)
         at oracle.reports.engine.EngineClassPOATie.getEnvs(EngineClassPOATie.java:152)
         at oracle.reports.engine.EngineClassPOA._invoke(EngineClassPOA.java:205)
         at oracle.reports.engine.EngineClassPOA._invoke(EngineClassPOA.java:62)
         at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2355)
         at com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:104)
         at com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.java:492)
         at com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapter.java:64)
         at com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAdapter.java:653)
         at com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.java:99)
         at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:76)

    Hi ,
    Looks like this is not a Forms side problem or even a Reports Servlet problem
    Some guesses.
    From the exception
    at oracle.reports.engine.EngineImpl.CGetEnv(Native Method)
    at oracle.reports.engine.EngineImpl.getEnvs(EngineImpl.java:453)
    it looks like engine crashing. Did you see the server GUI up and running ? Server might not have started
    Give
    rwserver server=<server_name> in command line.
    The server GUI should come up and show "ready "
    You have multiple Oracle Homes on the same machine. So this could be a PATH problem.
    1) Go to ControlPanel -> System - Advanced - Env variables - System Variables
    Copy the IDS specific PATH to clipboard
    Go to iDS_HOME\bin\ and open a command window. Set only the above PATH here. Start a standalone server
    rwserver server=<server_name>
    and try
    (If this works you could write a batch file later)
    2) For trouble shooting purposes use a different server name to start the standalone server.
    3) Also look in your registry
    HKLM\Software\Oracle\Home<x>\
    Here please see whether you have any "very long" environment variable (say more than 256 chars or 512 chars).
    This is just a guess.
    4) To confirm this is not a Reports servlet problem
    give
    rwclient report=<report_name> + ..... <server=server_name>
    If you get same error, then it is not a servlet problem. It could be that Reports server is crashing
    Thanks
    Ratheesh
    [    All Docs     ]
    http://otn.oracle.com/documentation/reports.html
    [     Publishing reports to web  - 10G  ]
    http://download.oracle.com/docs/html/B10314_01/toc.htm (html)
    http://download.oracle.com/docs/pdf/B10314_01.pdf (pdf)
    [   Building reports  - 10G ]
    http://download.oracle.com/docs/pdf/B10602_01.pdf (pdf)
    http://download.oracle.com/docs/html/B10602_01/toc.htm (html)
    [   Forms Reports Integration whitepaper  9i ]
    http://otn.oracle.com/products/forms/pdf/frm9isrw9i.pdf

  • "identifier DBMS_FGA must be declared" When called from PL/SQL package...

    Hi there,
    I am trying to call dbms_fga dynamically (of sorts) from a package, and I am getting the error as per the title.
    I have tried as many ways as i can think of calling this from another package, with similar results each time.
    The user/owner of the package has DBA rights, so it doesn't appear to be a permissions issue.
    Oracle Version is 11.1.0.6.0 on Suse.
    any ideas on this anyone?
    Cheers
    CODE:
    Attempt 1:
    PROCEDURE enable_sql_auditing (on_off in boolean default false) is
    v_ssql varchar2(900);
    cursor c1 is
    select table_name
    from all_all_tables
    where owner=gcv_pkg_owner;
    begin
    for rec in c1 loop
    sys.dbms_fga.add_policy(object_schema =>''|| gcv_pkg_owner ||'',
    object_name => ''|| rec.table_name ||'',
    policy_name => ''|| rec.table_name || '_AUDIT''',
    handler_schema => ''|| gcv_pkg_owner ||'',
    handler_module => 'FGA_SQL',
    enable => true);
    end loop;
    end enable_sql_auditing;
    Attempt 2:
    PROCEDURE enable_sql_auditing (on_off in boolean default false) is
    v_ssql varchar2(900);
    cursor c1 is
    select table_name
    from all_all_tables
    where owner=gcv_pkg_owner;
    begin
    for rec in c1 loop
    v_ssql := 'begin sys.dbms_fga.add_policy(object_schema =>''' ||gcv_pkg_owner|| ''', object_name => '''||rec.table_name||''', policy_name => '''||rec.table_name||'_AUDIT'', enable => true); end;';
    execute immediate (v_ssql);
    end loop;
    end enable_sql_auditing;

    Frenchwood wrote:
    The user/owner of the package has DBA rights, so it doesn't appear to be a permissions issue.But it is.
    DBA is a role.
    permissions within PL/SQL have to be directly granted rather than through roles.
    i.e. you need to directly grant execute permission on the package to the required user(s).

  • Why are Java SASLFactories missing when called via PL/SQL but not from JRE?

    Hi
    This may be quite a technical point about SASL and JCE Providers etc OR it may just be a question about how Oracle PL/SQL interfaces with Java.
    The background is that I am trying to get a Java opensource library to run in Oracle DB - this is for specialized communication from Database to other servers.
    The library uses a SASL mechanism to authenticate with the server and this (appears) to rely on JCE Providers installed and provided by the JRE.
    I have some Java code working which uses the library - this runs OK in NetBeans/Windows environment and also using Linux/Oracle JRE directly such as:
      +# $ORACLE_HOME/jdk/bin/java -classpath "./MyMain.jar:./OtherSupport.jar" package.TestClient+
    However it refuses to work (throws a NullPointerException) when called from PL/SQL.
      +FUNCTION send_a_message (iHost IN VARCHAR2,+
         iPort IN NUMBER,
        +iLogin IN VARCHAR2,+
        +iPasswd IN VARCHAR2,+
         iRecipient IN VARCHAR2,
         iMessage IN VARCHAR2) RETURN NUMBER
       AS LANGUAGE JAVA
       NAME package.TestClient.sendATextMessage(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String) return int';
    In the Java code this is:
       public static int sendATextMessage(String iHost,
         int iPort,
         String iLogin,
         String iPasswd
         String iRecipient,
         String iMessage)
    I've tracked the issue down to there being no SaslClientFactories (via Sasl.getSaslClientFactories()) showing when called from PL/SQL whereas 3 are available when run from within Java directly. This via:
       Enumeration<SaslClientFactory> facts = Sasl.getSaslClientFactories();
       System.out.println("Found Sasl Factories [" & (facts != null)  & "] size[" & Collections.list(facts).size() & "]");
    So, is there some aspect of Java initialisation that I'm missing when calling from PL/SQL (which means SASL factories aren't getting loaded into JRE) or is there something different in SASL setup?
    Any pointers appreciated.
    Thanks
    Dave

    Ok, after a bit of reading and general hacking about I have got this working.
    What I hadn't initially understood/remembered is that for a Stored Procedure the JVM installed on file system with Oracle isn't actually used - java code is loaded into the database and hence a different set of base functions are available. The following is a good explanation of this http://docs.oracle.com/cd/B14117_01/java.101/b12021/appover.htm#BGBIBDAJ
    So "out of the box" the Oracle Database appears to come loaded with only two of the Sun security providers i.e. no com.sum.security.SASL
    >
    OBJECT_NAME             OBJECT_TYPE     STATUS   TIMESTAMP
    com/sun/security/auth/NTSid  JAVA CLASS    VALID   2013-02-14:14:08:57
    com/sun/security/jgss/GSSUtil    JAVA CLASS    VALID   2013-02-14:14:08:57
    >
    This is from:
    >
    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 %' AND
       object_name LIKE 'com/sun/security%'
    ORDER BY
      object_type,
      object_name;
    >
    My solution (which may well be a work-around) is the following:
    1) Downloaded JDK Source and extracted "com.sun.security.sasl" java code to my project
    2) Added following code to my Stored Procedure ()
    >
    Enumeration<SaslClientFactory> saslFacts = Sasl.getSaslClientFactories();
    if (!saslFacts.hasMoreElements()) {
      System.out.println("Sasl Provider not pre-loaded");
      int added = Security.addProvider(new com.sun.security.sasl.Provider());
      if (added == -1) {
        System.out.println("Sasl Provider could not be loaded");
        System.exit(added);
      else {
        System.out.println("Sasl Provider added");
    >
    3) Built my JAR file with the sasl package embedded (note: could only find Java 6 code, so had to comment out some GSS lines - but wasn't intending to use these)
    4) Loaded JAR to oracle via "loadjava".
    5) Add permissions (only found this out after a couple of failed runs)
    >
    call dbms_java.grant_permission('XMPP', 'SYS:java.security.SecurityPermission', 'putProviderProperty.SunSASL', '' );
    call dbms_java.grant_permission('XMPP', 'SYS:java.security.SecurityPermission', 'insertProvider.SunSASL', '' );
    >
    6) Run gives the following:
    >
    Sasl Provider not pre-loaded
    Sasl Provider added
    ...etc...
    >
    It works!. I confess I'm not sure of the implications of this for multiple calls/performance and if it will need to be added for each stored procedure call - may post back.
    For completeness I should point out that after my load the Security providers look like this:
    >
    OBJECT_NAME             OBJECT_TYPE     STATUS   TIMESTAMP
    com/sun/security/auth/NTSid    JAVA CLASS    INVALID  2013-02-15:09:11:36
    com/sun/security/jgss/GSSUtil    JAVA CLASS    INVALID  2013-02-15:09:11:37
    com/sun/security/sasl/Provider    JAVA CLASS    VALID    2013-02-15:10:03:21
    >
    i.e. the original couple are "INVALID" !
    Dave
    Edited by: 946763 on Feb 26, 2013 2:35 AM

  • HR_INFOTYPE_OPERATION not working when called from Dynamic action

    Hi ,
           Senario  : I would like to execute a form from dynamic action which
    creates a record in 0015 (Additional payment IT) .
           I have writen the code as shown below am using FM HR_INFOTYPE_OPERATION
    . When i execute the program from se38 it is creating a record, however it is
    not created when it is called from dynamic action..when i debugged the code in
    inside the FM HR_INFOTYPE_OPERATION there is a FM HR_MAINTAIN_MASTERDATA where
    they are using call dialog (statement) and
    sy-oncom = 'N'   when called from Dynamic action and
    sy-oncom = 'S'   when called executed directly.
    I tried to change the sy-oncom to S while run from Dynamic action it created
    the record.
    So Can anyone explain me abt sy-oncom and how can i resolve the issue..
    code..
    REPORT ZHRPYENH01 .
    perFORM TERMIATION_9000.
    INCLUDE DBPNPMAC.
          FORM Termiation_9000                                          *
    FORM TERMIATION_9000.
    INFOTYPES : 0015.
    *data : i .
    *i ='c'.
    *break-point.
    *message i000(000) with i.
      TABLES : PRELP.
      DATA : P9000 TYPE PA9000." with header line.
      DATA : P0000 TYPE STANDARD TABLE OF  P0000 WITH HEADER LINE.
    DATA : P0015 TYPE STANDARD TABLE OF  P0015 WITH HEADER LINE.
      DATA : HIRE_DATE  LIKE SY-DATUM,
             TERM_DATE  LIKE SY-DATUM.
      DATA : MOLGA LIKE T500L-MOLGA VALUE '25',
             SEQNR LIKE PC261-SEQNR.
      DATA : RGDIR TYPE STANDARD TABLE OF PC261 WITH HEADER LINE.
      DATA : ACTUAL_PERIOD LIKE PA9000-RETENTION.
      DATA : PNP-SW-FOUND TYPE SY-SUBRC ,
             PNP-SY-TABIX TYPE SY-TABIX.
      DATA : TER_PERNR LIKE PA0001-PERNR.
      DATA : REF_PERNR LIKE PA0001-PERNR.
      data : key type BAPIPAKEY.
      data : payed_amount type p0015-BETRG.
    data : future_payment_amount type p0015-BETRG.
    data : p0002 like pa0002.
      types : begin of t_deduction ,
              deducation_date like p0015-begda,
              future_payment_amount type p0015-BETRG.
      types : end of t_deduction.
    data :  future_deduction type standard table of t_deduction with
    *header line.
      data :  future_deduction type  t_deduction .
    data : RETURN type  BAPIRETURN1.
    *data : deduction_p0015 like standard table of p0015 with header line.
    data : deduction_p0015 like p0015 .
    xxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxx
    ****Prepare 0015 data for deduction
    *deduction for payed amount
    clear deduction_p0015.
    *refresh deduction_p0015.
    deduction_p0015-pernr = REF_PERNR.
    *deduction_p0015-pernr = TER_PERNR.
    deduction_p0015-lgart = 'M120'.
    deduction_p0015-begda = sy-datum + 1 .
    deduction_p0015-endda = sy-datum + 1 .
    deduction_p0015-BETRG = payed_amount.
    deduction_p0015-WAERS = 'SGD'.
    deduction_p0015-ZUORD =  TER_PERNR.
    *append deduction_p0015.
    **deduction for future payment amount
    *loop at future_deduction.
    *clear deduction_p0015.
    *deduction_p0015-pernr = REF_PERNR.
    **deduction_p0015-pernr = TER_PERNR.
    *deduction_p0015-lgart = 'M120'.
    *deduction_p0015-begda = FUTURE_DEDUCTION-DEDUCATION_DATE.
    *deduction_p0015-endda = FUTURE_DEDUCTION-DEDUCATION_DATE.
    *deduction_p0015-BETRG = future_deduction-future_payment_amount.
    *deduction_p0015-WAERS = 'SGD'.
    *deduction_p0015-ZUORD =  TER_PERNR.
    *append deduction_p0015.
    *endloop.
    Create a deduction wage type in 0015 for the employee
    break-point.
    CLEAR RETURN.
    CALL FUNCTION 'BAPI_EMPLOYEET_ENQUEUE'
      EXPORTING
        NUMBER              = REF_PERNR
        VALIDITYBEGIN       = '18000101'
    IMPORTING
       RETURN              = return
    if not return is initial.
    message E000(000) with
    'Referred Employee could not be locked for referal  payment deducation,
    please try after some time'.
    endif.
    CALL FUNCTION 'HR_INFOTYPE_OPERATION'
      EXPORTING
        INFTY                  = '0015'
        NUMBER                 = REF_PERNR
       SUBTYPE                = 'M120'
      OBJECTID               =
      LOCKINDICATOR          =
       VALIDITYEND            = SY-DATUM
       VALIDITYBEGIN          = SY-DATUM
      RECORDNUMBER           =
        RECORD                 = deduction_p0015
        OPERATION              = 'COPY'
      TCLAS                  = 'A'
       DIALOG_MODE            = '2'
      NOCOMMIT               =
      VIEW_IDENTIFIER        =
      SECONDARY_RECORD       =
    IMPORTING
       RETURN                 = return
       KEY                    = key
    break-point.
    COMMIT WORK.
    if not return is initial.
    *return-TYPE
    *ID
    *NUMBER
    *MESSAGE
    message I000(000) with return-MESSAGE.
    endif.
    CALL FUNCTION 'BAPI_EMPLOYEET_DEQUEUE'
      EXPORTING
        NUMBER              = REF_PERNR
        VALIDITYBEGIN       = '18000101'
    IMPORTING
       RETURN              = return
    xxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxx
    Thanks and regards
    -Senthil Bala
    Message was edited by: senthil bala

    Hi Senthil
    Why at all U want a subroutine to create a record in IT0015 through Dynamic action.There are some standard codes available to update infotypes.
    Let me give U an example
    14     9CON     BETRG     4     2     I     INS,0015 This will create a record in IT0015 when IT0014 is updated with Wagetype 9CON
    14     9CON     BETRG     4     3     W     P0015-LGART='5400' Set wagetype for IT0015(Here U can use a subroutine call to set the wagetype)
    14     9CON     BETRG     4     4     W     P0015-BETRG=P0014-BETRG set amount for IT0015(Here U can use a subroutine call to get the amount)
    14     9CON     BETRG     4     5     W     P0015-BEGDA=P0014-ENDDA set the dates(Here U can use a subroutine call to set the dates)
    Hope this will help U.
    Please award points if helpful

  • Subtemplate footer is not coming when calling from the main template

    Hi All,
    The footer from the subtemplate is not coming in the output when calling from the main template. Does anybody worked on the subtemplate?
    If the same footer is put in the main template, it is displaying.
    Please respond as this is a critical issue for us.
    Thanks,
    Ambadas

    Hi Tim,
    Thanks for your reply. Here is syntax which I got from the Oracle BI Publisher blog. And this is to just test locally.
    http://blogs.oracle.com/xmlpublisher/2006/04/11?import:file:///C:/temp/HeaderFooter.rtf
    <?import:file:///d:/test/GEPOPRINT_GER_GER.rtf?>
    <?import:file:///d:/test/GEPOPRINT_US.rtf?>
    <?for-each@section:G_HEADERS?>
    <?if:POH_REPORT_NAME='GER PO w/GERMAN Data'?>
    <?call-template:PO_GERMAN?>
    <?end if?>
    <?if:POH_REPORT_NAME='US Purchase Order'?>
    <?call-template:PO_US?>
    <?end if?>
    <?End for-each?>
    And I don't have any footers in the main template but in the subtemplate I have the respective footers. If you want, I can send all the RTF's to you directly.
    Let me know.
    Thanks,
    Ambadas

  • Extensions still work when calling from outside but not in listed in DN

    Hello,
    There are 3 extensions that still work when calling from the outside, but they don't reside in the DN listing.  Where could they still exist?  Using Cisco Unified CM 8.5.1.                  
    Thank you for any assistance!

    Review you dial plan and also the unassigned DNs, they might not exist as an exact match, but maybe in something with wildcards.
    You can use DNA to search for them.
    HTH
    java
    if this helps, please rate
    www.cisco.com/go/pdihelpdesk

  • IPhone6 is not sending or receiving texts from non-Apple users, except when in Group texts. I've tried the various fixes on the main support page to no avail. Any ideas?

    iPhone6 is not sending or receiving texts from non-Apple users, except when in Group texts. I've tried the various fixes on the main support page to no avail. Any ideas?

    Have you contacted your carrier to make sure there's no issues with your account?
    ~Lyssa

Maybe you are looking for

  • Macbook Pro Randomly Goes to Sleep and Wont Wake Up

    My Macbook Pro started having this problem a few months ago and it has gotten progressivly worse and worse. It will randomly go to sleep but I wont be able to wake it back up. The keys are lit up and the light on the front is pulsing, but no matter w

  • 10.9.2 - Finder crashes every 5 seconds!!!

    I have a MacPro with 24GB of RAM, 6 core Intel Xeon CPU, 2012 tower. After the OSX 10.9.2 upgrade I had issues with the display port output on my graphics card. I resolved that issue temporerilly by using DVI-D and HDMI for both my monitors. Today, h

  • Wifi mob enterprise   serial number detection

    hi guys i was asking about something if its possible or not if there is wifi connection between mobile and server side using J2ME/J2ee mobile enterprise application and i need to detect automatic serial key of my smartphone once the connection is det

  • Search and highlight found sentence

    I'm designing a C# console application that searches sentences in a PDF text (i.e multiple words separated by space , and may be separated by line) and a title sentence that may take more than one line . I get the pdf text in a string then match the

  • Compare two members from the same dimension in HFR

    Hi, Is it possibe to compare two members from the same dimension in HFR? The requirement is to compare Year and Week members from the same dimension. The Week date will be selected from POV. The corresponding Year date should be displayed in the repo