Call.addNamedArgumentValue() ?

Folks
I am trying to call one stored procedure in Sybase, I am doing the following steps before executing any query
Vector objs = new Vector();
ReadAllQuery query = new ReadAllQuery();
query.setReferenceClass(tclass);
StoredProcedureCall call = new StoredProcedureCall();
call.addNamedArgumentValue(inParam.getArgument(), inParam.getValue()); <--- where inParam.getArgument() returns the input parameter name for the stored procedure and inParam.getValue() is the value for this,
call.useNamedCursorOutputAsResultSet(outParam);
call.setProcedureName(procName);
// Set the call on the query
query.setCall(call);
objs = (Vector) this.clientSession.executeQuery(query);
I am getting ClassCastException when i try to
call.addNamedArgumentValue(inParam.getArgument(), inParam.getValue());
Because i have some print statements before this call and after this call , but i am able to see only the print statements which is before the above call,
I do appreciate if any one could tell me if i am doing something wrong,
Can i straight away send the value to the stored procedure ? If so what is the method ?
Thanks
PM

Hi Gnanesh,
StoredProcedureCall's addNamedArgumentValue method takes the first parameter of type String, and the second of type Object.
Your code loks ok, except useNamedCursorOutputAsResultSet call - can you use a cursor as an output parameter with SyBase?

Similar Messages

  • Problem in calling stored Procedure through Toplink

    Hi ,
    I'm doing POC of calling stored thru toplink but facing some issues. Any pointers to it would be helpful.
    This is my javaCode used to call stored proc through toplink:-
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("testdeleteLeafBox");
    call.addNamedInOutputArgumentValue(
    "box_id", // procedure parameter name
    new Integer("1455"), // in argument value
    "box_id", // out argument field name
    Integer.class // Java type corresponding to type returned by procedure
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    Integer metricLength = (Integer) session.executeQuery(query);
    My Stored Procedure is :-
    create or replace procedure testdeleteLeafBox(
    v_box_id IN NUMBER ,
    result OUT number
    is
    v_result number;
    BEGIN
    SELECT client_id INTO v_result FROM tb_gvhr_box WHERE box_id=v_box_id;
    result:=v_result;
    end testdeleteLeafBox;
    Thrown exception is :-
    [TopLink Warning]: 2006.02.24 06:35:47.077--DatabaseSessionImpl(650)--Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'TESTDELETELEAFBOX'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    Call:BEGIN testdeleteLeafBox(box_id=>?); END;
         bind => [1455 => box_id]
    Query:ValueReadQuery()
    Exception breakpoint occurred at line 1927 of Session.java.
    oracle.toplink.exceptions.DatabaseException: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'TESTDELETELEAFBOX'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    The stored procedure defined in the db has one IN and one OUT parameter, therefore in StoredProcedureCall you'll need to have one IN one OUT parameter as well (instead of a single INOUT):
        call.addNamedArgumentValue(
            "v_box_id", //procedure IN parameter name
            new Integer("1455"));
        call.addNamedOutputArgument(
            "result",  //procedure OUT parameter name
            "box_id", // out argument field name
            Integer.class // OUT parameter Java type);

  • Call function from data base with clob input parameter.

    Hello,
    In this project I use Jdev 11g.
    I call function from database.
    create or replace function get_fa_list (
    p_fa_id_list in clob
    return sys_refcursor
    is
    vCursor sys_refcursor;
    begin
    put_msg ('begin');
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;
    put_msg ('Save');
    open vCursor for
    select rownum as id, s.*
    from (
    select f.latitude, f.longitude, count (distinct f.res_id) as res_count, count (*) as fa_count, 16711680 as color, res_concat_distinct (f.res_id) as station_list
    from mv_frequency_assignment f, table (SplitClob (p_fa_id_list, ',')) l
    where f.ext_system = 'BI' and
    f.ext_sys_id = l.column_value
    group by f.latitude, f.longitude
    ) s;
    put_msg ('Open and End');
    return vCursor;
    end get_fa_list;
    I use TopLink in ejb.
    i use follow code for call function and get result.
    public List<TmpResPoints> findAllPointsBI(String p_id){
    UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
    uow.beginEarlyTransaction();
    StoredFunctionCall call = new StoredFunctionCall();
    call.setProcedureName("get_fa_list");
    call.useUnnamedCursorOutputAsResultSet();
    ClobDomain c = new ClobDomain(p_id);
    //System.out.println(c.toString());
    call.addNamedArgumentValue("p_fa_id_list", c);
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(TmpResPoints.class);
    query.setCall(call);
    List<TmpResPoints> result = (List<TmpResPoints>)uow.executeQuery(query);
    uow.commit();
    uow.release();
    return result;
    But size parameter "p_fa_id_list" is 0. (geting from temp table in Data base). this code in function >>
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;)
    How I can call this function from dataBase and get result?
    thx,
    Demka.

    What is the SQL generated?
    The argument should just be the Clob value (a String) not the domain object.
    Also try addNamedArgument, and then pass the named argument to the query.
    James : http://www.eclipselink.org

  • Invoking Stored Procedure with OUT Parameter

    I am calling a stored procedure that has a "out" parameter of PL/SQL type (table of varchar2) through toplink API. My procedure executes, performs the updates successfully, but I can not obtain the value of the out parameter. Is the approach followed below incorrect? I could not figure out by looking into examples provided in the documentation:
    http://download.oracle.com/docs/cd/B25221_04/web.1013/b25386/building_and_using_application_services009.htm#BCFEFAHC
    Java function is given below:
    public List removeFromAutoupdSched( List srNumbers, String userName)
    if (srNumbers == null || srNumbers.size() == 0)
    return null;
    List result = null;
    try
    //Example Stored procedure call with an output parameter
    DatabaseLogin login = m_dbSess.getLogin();
    Connection conn = (Connection) (java.sql.Connection)login.connectToDatasource(null);
    oracle.sql.ArrayDescriptor arrDesc = new oracle.sql.ArrayDescriptor("AUTOUPD_SRLIST_T", conn);
    oracle.sql.ARRAY srARR = new oracle.sql.ARRAY(arrDesc, conn, srNumbers.toArray());
    StoredProcedureCall procCall = new StoredProcedureCall();
    procCall.setProcedureName("SEW_AUTOUPD.PURGE_AUTOUPD_SCHEDULE");
    procCall.addNamedArgumentValue("excludeSRlist", srARR);
    procCall.addNamedArgumentValue("exclude_by", userName);
    procCall.addNamedOutputArgument(
    "excludeSR_srlist_status",
    "excludeSR_srlist_status",
    OracleTypes.ARRAY,
    "AUTOUPD_SRLIST_ERRS_T"
    ValueReadQuery vq = new ValueReadQuery();
    vq.setCall(procCall);
    oracle.sql.ARRAY srResultARR = (oracle.sql.ARRAY)m_dbSess.executeQuery(vq);
    if (srResultARR != null)
    String[] msgs = (String[])srResultARR.getArray();
    if (msgs.length > 0)
    result = Arrays.asList(msgs);
    Iterator iter = result.iterator();
    while (iter.hasNext())
    System.out.println("msg = " + iter.next());
    return result;
    catch (Exception exc)
    throw new RuntimeException(exc);
    PL/SQL Type
    create or replace TYPE autoupd_srlist_errs_t IS TABLE OF VARCHAR2(150);
    Sample procedure called by toplink:
    PROCEDURE purge_autoupd_schedule(
    excludeSRlist autoupd_srlist_t,
    exclude_by VARCHAR2,
    excludeSR_srlist_status OUT NOCOPY autoupd_srlist_errs_t)
    IS
    pkg sew_log.pkg_name%TYPE default upper('sew_autoupd');
    prc sew_log.prc_name%TYPE default upper('purge_autoupd_schedule(excludeSRlist, exclude_by)');
    srno NUMBER;
    -- cnt NUMBER := 0;
    exclude_status VARCHAR2(150);
    err_prefix VARCHAR2(50) := 'Unable to exclude from autoupdate, ';
    BEGIN
    FOR i IN excludeSRlist.FIRST..excludeSRlist.LAST
    LOOP
    BEGIN
    srno := excludeSRlist(i);
    -- Update actn_taken column in autoupd_schedule before doing delete.
    UPDATE autoupd_schedule SET actn_taken='Removed by engineer', UPD_TIME=systimestamp
    WHERE sr_no = srno and engr_itsid = exclude_by;
    -- Add SR to exclusion list.
    INSERT INTO autoupd_exclude(sr_no, exclude_by, exclude_time) VALUES (srno, exclude_by, systimestamp);
    exclude_status := 'Item ' || i || ' - SR ' || srno || ' - ' || 'Excluded from autoupdate.';
    excludeSR_srlist_status(i) := exclude_status;
    EXCEPTION
    WHEN others THEN
    -- Add SR to excludeSR_fail if previous steps occurred okay.
    -- cnt := cnt +1;
    exclude_status := 'Item ' || i || ' - SR ' || srno || ' - ' || err_prefix || substr(sqlerrm,12);
    excludeSR_srlist_status(i) := exclude_status;
    END;
    END LOOP;
    EXCEPTION
    WHEN others THEN
    sew_logger.log(
    code => substr(sqlerrm,1,9),
    msg => substr(sqlerrm,12),
    pkg => pkg,
    prc => prc
    END;
    Any help is appreciated.

    What happens if you run the stored procedure through pure jdbc (without TopLink)?
    I tried a simple example that worked for me:
    //defined type in the db
    CREATE TYPE "TEST"."VAR_LIST" AS  TABLE OF VARCHAR2(150)
    //defined stored procedure in the db
    CREATE OR REPLACE  PROCEDURE "TEST"."VAR_LIST_IN_OUT"  (
    VARS_IN VAR_LIST,
    VARS_OUT OUT NOCOPY VAR_LIST
    as
    begin
      VARS_OUT := VAR_LIST();
      FOR i IN VARS_IN.FIRST..VARS_IN.LAST LOOP
        VARS_OUT.EXTEND;
        VARS_OUT(i) := CONCAT(VARS_IN(i), '_BLAH');
      END LOOP;
    end;
    // Java code
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("VAR_LIST_IN_OUT");
    Connection conn = (Connection) ((oracle.toplink.internal.sessions.AbstractSession)getSession()).getAccessor().getConnection();
    oracle.sql.ArrayDescriptor arrDesc = new oracle.sql.ArrayDescriptor("VAR_LIST", conn);
    oracle.sql.ARRAY srARR = new oracle.sql.ARRAY(arrDesc, conn, new String[]{"A1", "A2", "A3"});
    call.addNamedArgumentValue("VARS_IN", srARR);
    call.addNamedOutputArgument("VARS_OUT", "VARS_OUT", Types.ARRAY, "VAR_LIST");
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    Object result = getSession().executeQuery(query);
    Object[] array = (Object[])((java.sql.Array)result).getArray();
    for(int i=0; i<array.length; i++) {
        System.out.println(array);
    // System.out:
    [TopLink Finest]: 2008.04.25 15:37:16.687--DatabaseSessionImpl(3491657)--Thread(Thread[main,5,main])--Execute query ValueReadQuery()
    [TopLink Fine]: 2008.04.25 15:37:16.703--DatabaseSessionImpl(3491657)--Connection(29118152)--Thread(Thread[main,5,main])--BEGIN VAR_LIST_IN_OUT(VARS_IN=>?, VARS_OUT=>?); END;
         bind => [oracle.sql.ARRAY@323274, => VARS_OUT] (There is no English translation for this message.)
    A1_BLAH
    A2_BLAH
    A3_BLAH
    My stored procedure didn't work (on Oracle 9 db) without output collection initialization: VARS_OUT := VAR_LIST(); and extending: VARS_OUT.EXTEND.

  • Can I get handle to Database Row before an entity is deleted

    Hi,
    We are using stored procedure to list, insert , update and delete entity objects.To use the stored procedure I override the default queries generated by Toplink and make use of the stored procedure query.The issue here is that my Stored Procedure requires more arguments (like name of the user doing the insert) than there are fields in the entity.I need to provide these argument values to the call.For this I do something like
    session.getDescriptor(MyClass.class).getEventManager().addListener(new DescriptorEventAdapter(){
         public void aboutToInsert(DescriptorEvent evt) {
         evt.getRow().put("USER",evt.getSession().getProperty("username"));
    I set the username in the unitOfWork out of which I can grab the value in the eventHandler and put it inside the row just before insert.I do the same for modify too.But I dont see a similar methods for "delete".Do we have a aboutToDelete() method where I can get a handle to the row.The preDelete() does not provide a handle to the row.How can I insert additional arg values to the delete query?
    Thanks,
    Harini

    Hello Harini,
    Wow, you are correct there is no aboutToDelete, I guess manipulating the row before deletetion is not that common for our TopLink clients as this is the first request I have heard for it. I will add this request to our enhancement database. You might want to follow it up with support if it is a priority for you.
    As a workaround you could use the preDelete event to change the stored procedure call with the user name argument (i.e. build the procedure call dynamically in preDelete and set it into the query. The query will have been cloned at this point so there should be no concurrency issues. Make sure when doing this that you do not set the deleteQuery in the descriptor query manager as this will override the original query if set.
    Example:
    descriptor.getEventManager().addListener(new DescriptorEventAdapter() {
    public void preDelete(DescriptorEvent event) {
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("Delete_proc");
    call.addNamedArgument("P_ID", "ID");
    call.addNamedArgumentValue("USER", "scott");
    call.addNamedArgumentValue("TIME", new java.util.Date());
    event.getQuery().setCall(call);
    });

  • HOW TO USE STORED PROCEDURE IN JDEVELOPER - TOPLINK

    -- I really have problem try to do that!!!..
    I put the code of adf guide for toplink but have two errors:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("CHECK_VALID_POSTAL_CODE");
    call.addNamedArgument("POSTAL_CODE");
    call.addNamedArgumentValue("L5J1H5");
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    Number isValid = (Number) session.executeQuery(query);
    error:
    - call.addNamedArgumentValue("L5J1H5"); is not accepted
    - session.executeQuery(query); there is no session var defined
    Can someone tell me the correct form to call store procedure using a method for commandbutton??
    Message was edited by:
    user572789

    Hi Amol,
    Are you able to execute your stored procedure from oracle?.
    - If "Yes" then use  the Crystal Report XIR2 Designer to create the report.
    - Import this report in the Crystal Report For Eclipse Workbench.
    - The latest version for Crystal Report For Eclipse is SP1.
    Please let me know the results.
    Thanks,
    Neeraj

  • VARRAY as Stored Proc output parameter

    VARRAY as Stored Proc output parameter
    I have an Oracle VARRAY data type declared as follows:
    CREATE TYPE NUMBER_ARRAY AS VARRAY(100) OF NUMBER;
    I have a stored procedure which takes a single input and
    returns a NUMBER_ARRAY as output:
    CREATE OR REPLACE PROCEDURE one_in_number_array_out(
    IN_PARAM IN NUMBER,
    OUT_NUMBER_ARRAY OUT NUMBER_ARRAY )
    IS
    BEGIN
    -- OUT_NUMBER_ARRAY getting populated here
    END one_in_number_array_out;
    I want to be able hit this proc using TopLink StoreProcedureCall objects and retrieve through a map.
    I thought I would be able to do something like:
    public void execute() {
         StoredProcedureCall call = new StoredProcedureCall();
              call.setProcedureName( getStoredProcedureName() );
              call.addNamedArgumentValue("IN_NUMBER_PARAM", new Double(324) );
              call.addNamedOutputArgument("OUT_NUMBER_ARRAY", "numberArray"); // use an alias
         ClientSession clientSession = .....getClientSession();
    // EXCEPTION OCCURS on following call:
              Map row = (Map) clientSession.executeSelectingCall( call ).firstElement();
              Object numberArray = row.get( "numberArray" );
              System.out.println("numberArray = " + numberArray);
    But, when I call the stored proc I get the following stack trace:
    LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3 (Build 423)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'ONE_IN_NUMBER_ARRAY_OUT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    INTERNAL EXCEPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'ONE_IN_NUMBER_ARRAY_OUT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ERROR CODE: 6550
         at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
         at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.executeNonCursor(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ClientSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeSelectingCall(Unknown Source)
         at com.gs.lab.rr.db.plsql.gs_practice_pkg.OneInNumberArrayOutStoredProcedure.execute(OneInNumberArrayOutStoredProcedure.java:51)
         at com.gs.lab.rr.db.plsql.gs_practice_pkg.PracticeStoredProceduresTest.testOneInNumberArrayOutStoredProcedure(PracticeStoredProceduresTest.java:54)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:329)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151)
    INTERNAL EXCEPTION STACK:
    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'ONE_IN_NUMBER_ARRAY_OUT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
         at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.executeNonCursor(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ClientSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeSelectingCall(Unknown Source)
         at com.gs.lab.rr.db.plsql.gs_practice_pkg.OneInNumberArrayOutStoredProcedure.execute(OneInNumberArrayOutStoredProcedure.java:51)
         at com.gs.lab.rr.db.plsql.gs_practice_pkg.PracticeStoredProceduresTest.testOneInNumberArrayOutStoredProcedure(PracticeStoredProceduresTest.java:54)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:329)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151)
    Thanks in advance,
    John

    Using the SQL/ObjectRelational types as stored procedure arguments is not supported. But it may work...
    You should not pass in the reference to the array type. Instead, do something like this:
    call.addNamedOutputArgument("OUT_NUMBER_ARRAY", "OUT_NUMBER_ARRAY");
    Hope this helps. If not, I suspect it would take some technical services to do this as I don't think the source.zip contains the classes involved in this.
    - Don

  • Creating Named Query: from OracleCallableStatement

    We have a great many PL/SQL Procs in an existing legacy system that return PL/SQL Boolean, that we wish to call from toplink.
    Ideally we would like to create Toplink Nameded queries that wrap the SQL call statements.
    Does anyone know if its possible to convert a call like the following into a Toplink named query?
    String domain = "COST CENTRE";
    String value = "OP";
    OracleCallableStatement xcall = (OracleCallableStatement) con.prepareCall(
    "BEGIN ? := SYS.SQLJUTL.bool2int(is_valid_value(?, ?)); END;");
    xcall.registerOutParameter( 1, OracleTypes.INTEGER);
    xcall.setString(2,domain);
    xcall.setString(3,value);
    xcall.execute();
    System.out.println ("Status = " + xcall.getInt(1));
    FUNCTION is_valid_value(
    p_rv_domain IN CG_REF_CODES.RV_DOMAIN%TYPE,
    p_rv_low_value IN CG_REF_CODES.RV_LOW_VALUE%TYPE
    RETURN BOOLEAN
    IS
    Many thanks,
    Lee.

    You can define Stored Procedure calls in TopLink through the StoredProcedureCall class. StoredProcedureCall allows you to define output parameters to access return values.
    Example:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("is_valid_value");
    call.addNamedArgumentValue("DOMAIN", domain);
    call.addNamedArgumentValue("VALUE", value);
    call.addNamedOutputArgument("RESULT", "RESULT", Integer.class);
    List results = session.executeSelectingCall(call);
    boolean value = ((Integer) ((Map) results.get(0)).get("RESULT")).intValue() == 0;
    However what you seem to be accessing is a stored function, not a procedure. To access a stored function from TopLink you must use an SQLCall and select the return value through the DUAL table.
    Example:
    SQLCall call = new SQLCall("Select SYS.SQLJUTL.bool2int(is_valid_value(" + domain + ", " + value + ")) from dual");
    List results = session.executeSelectingCall(call);

  • How to use oracle.sql.* package?(in nls_charset12.zip)

    is there anyone could tell me how to use the method in this package? for i want to convert a character set from the database (solaris)default character set to the client(win2000) while storing data into ResultSet.
    or anyway that could chnage it would be appricate.
    thanks in advice,

    Hello Gaurav,
    First off, not sure why you are calling
    call.addNamedArgument("JOB_ID", "JOB_ID_I");
    call.addNamedArgumentValue("JOB_ID", jobId);
    You should call the first statement to indicate you will be adding in a "JOB_ID_I" argument to the query, or the second statement to add the value directly to the call, but not both. Calling both indicates your procedure is expecting two parameters called "JOB_ID" and you will get an exception if you do not define the "JOB_ID_I" argument on the query and pass in a parameter for it.
    TopLink does not currently create Oracle objects such as Structs and VARRAYs for you from java objects - atleast not for stored procedures arguments, as it does not know how or what to convert them to. You will need to create the Oracle object type yourself, and pass it into the query. I have not tested it, but it would look something like:
    UnitOfWork unitOfWork = getUnitOfWork();
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("DSM_JOB_PKG.INSERT_JOB_RUN_LOG");
    String jobId = jobIdItr.next().toString();
    call.addNamedArgumentValue("JOB_ID_I", jobId);
    Timestamp sysdate = BeanConvertUtil.getCurrentTimestamp();
    call.addNamedArgumentValue("ORDER_DATE_I", sysdate);
    call.addNamedArgumentValue("USER_ID_I", userId);
    Connection con = getSession().getAccessor().getConnection();
    oracle.sql.ArrayDescriptor anArrayDescriptor = new oracle.sql.ArrayDescriptor("GENERIC_STRING_TYPE",con);
    oracle.sql.ARRAY anARRAYin = new ARRAY(anArrayDescriptor, con, paramTypeIds );
    call.addNamedArgumentValue("JOB_PARAM_TYPE_IDS_I", anARRAYin );
    oracle.sql.ARRAY anARRAYin2 = new ARRAY(anArrayDescriptor, con, paramValues);
    call.addNamedArgumentValue("JOB_PARAM_VALUES_I", anARRAYin2 );
    session.executeSelectingCall(call);

  • Treat objects from named query as new ones

    Hello,
    I use TopLink 11.1.1.1.0 and I need to do following. I want to read object from database with named query and let TopLink treat them like new object created in java. Is it possible? Obejcts are in one table but the named query computes them with select from several different tables, so this obejcts are not present in the table.
    Why I need it? It is import of data from one module of our application to another. Previously it was done in java. About 500 000 objects were read in one module just to convert into 20 000 objects in another module. If database does this conversion (named query with grouping which reads the 20 000 objects) it is much faster and take much less memory.
    What I can do is to create new class with the same fields query this objects and then copy them to object I need. But I don't like creating new class just for this.
    Thank for any help
    Frank

    Thanks for help I solved it different way eventually. I made a stored procedure which inserts data to the table of SOURCE_ITEMS. First I call stored procedure, then I load all new created SOURCE_ITEMS with ReadAllQuery (I have business parameters by which to select them) and make post processing in java with them. I used StoredProcedureCall in TopLink so if exception occurs and transaction rollbacks, stored procedure will rollback as well (I tried it, works for sure:).
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName(SQL_IMPORT_CALL);
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_1, getId());
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_2, getXXX().getId());
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_3, getYYY.getId());
    call.addNamedArgumentValue(SQL_IMPORT_PARAM_4, getZZZ());
    DataModifyQuery query = new DataModifyQuery();
    query.setCall(call);
    query.setShouldBindAllParameters(true);
    // insert of imported SOURCE_ITEMS
    ctx.executeQuery(query);
    Thanks Chris and hope this will help to somebody else as well..
    Frank
    Edited by: user604333 on Nov 17, 2010 12:20 PM
    Edited by: user604333 on Nov 17, 2010 12:20 PM
    Edited by: user604333 on Nov 17, 2010 12:20 PM

  • How to get CLOB from stored procedure via StoredProcedureCall

    hi all
    I got "sp" on server : procedure get_text(p_in in varchar2, o_list out clob);
    in code:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("get_text");
    call.addNamedArgumentValue("p_in", new String("MyList"));
    call.addNamedOutputArgument("o_list"); // <- out CLOB
    Vector v = (Vector)this.m_UnitOfWorkt.executeSelectingCall( call ); // <- here I got error
    but if o_list is varchar is all ok
    so how to get data from clob?
    Please help
    Regards
    Krzysztof

    Post Author: achaithanya
    CA Forum: Data Connectivity and SQL
    I'm connecting to database through stored procedure only.We have sybase installed on our local system so that we are given permissions only to access the stored procedures.When u see the fields in CR XI i.e Field explorer you are able to see only 1st result fileds.I connected to sybase and there i'm able to see the output of 1st & 2nd Result set.
    Regards,
    Chaithanya.

  • Oracle.TopLink - execute function on server

    Hi all.
    I got problem. I know how to execute procedure with parameters on server, sample:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("get_bank_units");
    call.addNamedArgumentValue("id", new Integer(4));
    call.addNamedArgumentValue("name", new String("Main"));
    call.addNamedOutputArgument("o_list");          
    // execute stetment via ...
    ServerSession.aquireUnitOfWork.executeSelectingCall( call);
    it's simple but how do this if "get_bank_units" is not procedure but function??
    Please sample?...
    Regards
    Krzysztof
    PS. If it's not a problem please send sample on [email protected]

    How are you using Tomcat with SAP?
    Here's a good site for Tomcat:
    http://www.jguru.com/faq/Tomcat

  • Using Datasource with Toplink

    Hi,
    I am using toplink 10.1.3 .We are using the datasource to connect to weblogic connection pool.
    My session.xml is like this:
    - <login xsi:type="database-login">
    <platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</platform-class>
    <user-name />
    <datasource>jdbc/ds</datasource>
    </login>
    In the java DAO part,I need a physical database connection to get the ArrayDescriptor.The part of java code is below
    java.sql.Connection dbconnection=null;
    DatabaseLogin login = serverSession.getLogin();
    dbconnection=(java.sql.Connection)login.connectToDatasource(null);
    Questions:
    1.Is the above correct way to get the Physical JDBC connection from a weblogic connection pool(configured using datasource).
    2.How will the Connection released to the pool?Should i use dbconnection.close() or clientSession.release().
    Thanks

    Thanks doug for your reply.
    I am using datasource to connect to the weblogic 9.2 connection pool.
    My specific use case is this.
    I am executing a Stored procedure which will takes a Oracle user defined data type as an Input paramater.
    some steps we use in the java code for the above use case.
    --Getting the  toplink session
    ServerSession serverSession = TopLinkGenericDAO.getSession();
    clientSession = serverSession.acquireClientSession();
    --For getting the oracle user defined array
    java.sql.Connection dbconnection=null;
    DatabaseLogin login = serverSession.getLogin();
    dbconnection=(java.sql.Connection)login.connectToDatasource(null);
    oracle.sql.ArrayDescriptor descriptor = new oracle.sql.ArrayDescriptor(
    "STRING_ARRAY", dbconnection);
    oracle.sql.ARRAY arr_ORCL = new oracle.sql.ARRAY(descriptor,
    dbconnection, aIncl_Vin);
    --for executing stored procedure
    StoredProcedureCall call = new StoredProcedureCall();
    DataReadQuery dbquery = new DataReadQuery();
    call.setProcedureName(CVeITDAOConstants.INSERT_PING);
    call.addNamedArgumentValue("para1", arr_ORCL );
    dbquery.setCall(call);
    --release connection in the finally block
    finally
    clientSession.release();
    dbconnection.close();
    The above code fails when we execute it for 150 concurrent connection(using JMeter) with connection fail exception.
    Please let me know how do i release the physical jdbc connection(dbconnection) in the finally block.
    do we need to give dbconnection.close() or just by giving clientSession.release() will also release the jdbc connection.
    Thanks.

  • UnitOfWork and server session cache

    Hello,
    seems like in some situations UoW does not update server session cache:
    SessionManager manager = SessionManager.getManager();
    Server server = (Server) manager.getDefaultSession();
    Session client = server.acquireClientSession();
    UnitOfWork unit = client.acquireUnitOfWork();
    // stored procedure call preserves caching !
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("security.set_current_user");
    call.addNamedArgumentValue("p_user", 123);
    unit.executeNonSelectingCall(call);
    // these objects should always be cached (if caching is enabled) !
    List list = unit.readAllObjects(Naudotojas.class);
    unit.commit();
    client.release();
    server.release();
    The presented source code executes stored procedure and read query within singe transaction. Problem is that selected data is not cached. But if stored procedure call is removed, then records will be cached. Is it expected behaviour ? That workarounds could be applied to force caching ?

    When the first modify call is performed in a UnitOfWork it then assumes that the transactional state of the database is transient and therefore and data read could be non-committed. At this point it is not safe to load the objects into the shared cache.
    If you are attempting to make use of VPD security you should read up on the support offered in TopLink. It will give you additional call-backs for setting the user credentials.
    Doug

  • Baffled by Toplink and stored procedures

    Here's what I'm after...
    I have a nice package built to act as a bridge to a MySQL database. Everything works fine, but I need to write classes to "wrap" two stored procedures (procedures, not functions or triggers, defined in the database itself). I want to leverage the TopLink connection handling so that I don't have to open/close connections for these two classes. Surely there is some way to do this.
    Working with one example...
    Stored Procedure definition:
    CREATE PROCEDURE openPorts (ipAddr INT UNSIGNED)
    BEGIN
      DECLARE lastScanID INT UNSIGNED;
      SELECT results.scanrequestid INTO lastScanID
        FROM (results,network,scanner)
        WHERE
          results.ip=ipAddr and
          results.ip between network.ip and network.ip+pow(2,(32-network.cidr))-1 and
          results.scannerip=scanner.ip and
          scanner.regionid=network.regionid
        ORDER BY results.endtime DESC LIMIT 1;
      SELECT distinct protocol,port
        FROM results
        where
          ip=ipAddr and
          scanrequestid=lastScanID and
          port>0 and protocol>0
        ORDER BY PROTOCOL,PORT;
    ENDI want to create a class file OpenPortsDAO such that calling
    List<OpenPort> ports = OpenPortsDAO.find(int ipInteger)Yields a list (or vector, whatever) of the rows returned as the result.
    Ignoring for the moment the issues with mapping returned row fields to object fields in my OpenPort class, how the heck do I...
    1) Define the stored procedure
    2) Set the input variable value
    3) Get the connection (if necessary)
    4) Execute the query
    I imagine it's going to be something like...
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("hostSummary");
    call.addNamedArgumentValue("ipAddr", value);
    call.getResult();Should this wrapping class be defined in the persistence unit just like any other? If so, my assumption is then that I would not have to manually handle connections, etc.
    Any help would be very much appreciated. I think if I can just get pointed in the right direction, it should "click" for me.
    -David

    Doug,
    Thanks for the info. I was able to handle the stored procedure, but I did so via POJOs.
    I'm interested in this part of your reply...
    >
    This will give you an entity class with a full lifecycle to it assuming that TopLink may write it back to the database if modified in a transaction.
    Given the following pseudo-&lt;code|SQL>...
    drop table starship
    go
    drop table contractor
    go
    create table contractor (
    id serial primary key,
    name text unique)
    go
    create table starship (
    id serial primary key,
    name text unique,
    contractor_id int references contractor)
    go
    create function get_by_id(shipid int, OUT contractor, OUT shipname)
    BEGIN
      blah
    END;
    GOAre you saying that I can create a full CRUD object for the function/procedure call? IE., assuming I get back a result and I see that the ship name is incorrect, I could make a change to the returned data and have that persisted? Without having to get a starship object on my own?
    If that's the case, I'd like to know more.
    -David

Maybe you are looking for

  • Transfer everything from iPhone 3GS to iPhone 4

    What should I do? simply plug in the 3GS to laptop, and let it 'sync'? Really dun want to lose all apps & pics inside Thx

  • JMF- Problem in inbuilt Webcam using JMStudio

    Hi All, I am using Java Media Framework 2.1.1e and I am currently facing issues while accessing my inbuilt webcam using JMStudio I have tried to access my in-built Web-Camera from JMStudio app(of JMF..File->Capture->check 'Use video device'-> Press '

  • Install acrobat 9 over 5

    I am  trying to install Acrobat 9.  I currently have Acrobat 5.  I get an error message telling me I must uninstall 5 and I should click continue to uninstall 5.  I click on continue and then get an error message that tells me the setup was interupte

  • ADF Security Log Out issue

    Hi, We have implemented ADF security and using form based authentication. The problem we are facing is during logout, in IE we see a NullPointerException, before the login page is displayed. Please note that this functionality works fine in Firefox a

  • My "edit playlist" button has disappeared!

    Recently, my "edit playlist" button has disappeared all together when I right-click a playlist. I do know how to manually add to a playlist, but it's inconvenient. It's there when I click File, but I can't click on it. I've tried calling Apple, but o