Problem calling Stored Procedure returning SETOF UDT (Using Spring)

I am using Spring's StoredProcedure class to call a stored procedure from a PostgreSql database. It returns a set of user defined data types. I'm having a problem in parsing the results returned.
The user defined data type :
CREATE TYPE process_states AS (
process_name text,
process_type text
The stored procedure returns a SET of "process_state" :
CREATE FUNTION inquire_process_state (.....)
RETURNS SETOF process_state AS '
SELECT ....
I hava a Java class extending the Spring StoredProcedure classs.
public MyProcStats extends StoredProcedure {
private class ProcStateCallBackHandler implements RowCallBackHandler {
public void processRow(ResultSet rs) throws SQLException {
System.out.println(rs.getString(1));
public MyProcStats (DataSource ds) {
super(ds, "inquire_process_state");
super.setFunction(true);
declareParameter(new SqlOutparameter("rs", Types.OTHER, new ProcStateCallBackHandler());
declareParameter(new SqlParameter("family_name", Types.VARCHAR) ;
While testing this class, I get an errormessage
"java.sql.SQLException:ERROR: cannot display a value of type record"
I would appreciate if anyone can point out my mistakes. I tried declaring
new SqlOutParameter("rs", Types.OTHER, "process_state"), but that didn't help.

As the related posts suggest, you will need to use direct JDBC code for this.
Also I'm not sure JDBC supports the RECORD type, so you may need to wrap your stored functions with ones that either flatten the record out, or take OBJECT types.

Similar Messages

  • Weird Problem calling Stored Procedure using JDBC

    Scenario is..
    I have J2EE application and calling stored procedure using JDBC.
    My application connects to instance "A" of testDB.
    Schema "A" does NOT own any packages/procedure but granted execute on oracle packages/procedures that reside in schema "B" of testDB.
    In java code I call procedure(proc1) in package(pac1) which internally calls procedure(proc2) in package(pac2).
    The problem occurs when procedure pac2.proc2 is modified. After the modification, my java code fails and throws an exception "User-Defined Exception" and I am also getting "ORA-06508: PL/SQL: could not find program unit being called". This clears up only if I bounce the web container. (This doesn't happen if I modify pac1.proc1 and run my application)
    Has any one faced this problem? Please suggest if any thing can be changed in jdbc code to fix this problem.
    Thanks

    Hi,
    I assume these are PL/SQL packages and that the changes are made at the package specification level?
    If so, it looks like you are hitting the PL/SQL dependencies rules. In other words, if the spec of proc2 is changed, then proc1 is invalidated, since proc1 still depends on the old version of proc2's spec. As a result, if you try to run proc1, its spec must either be explicitly rewritten before it could run again or implicitly recompiled first, if the (implicit) recompilation fails, it won’t run.
    Kuassi http://db360.blogspot.com

  • Error in calling Stored procedure returns REFCURSOR

    Hi,
    I've written a oracle stored procedure returning REFCURSOR. say,extractorderdespatchconfirmsp('','','','','','H1','ACG','','','','',:rc).
    Following statement throwing error.
    CallableStatement cs = con.PrepareCall("{extractorderdespatchconfirmsp('','','','','','H1','ACG','','','','',:rc)}");
    rs = cs.executeQuery();
    Could you rectify this problem and give me the currect code.
    riyaz

    Your naming convention leaves a little to be desired.
    String command = "{CALL extractorderdespatchconfirmsp(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
    CallableStatement cstmt = conn.prepareCall(command);
    //set the variables here ie, dates need to be a timestamp format. use set timestamp.
    cstmt.setInt(1, 2);
    cstmt.setString(2, "a string");
    cstmt.setInt(3, 0);
    //for return values
    cstmt.registerOutParameter(3, Types.INTEGER);
    cstmt.registerOutParameter(2, Types.INTEGER);
    cstmt.execute();
    int status = cstmt.getInt(3);
    int status2 = cstmt.getInt(2);
    cstmt.close();
    It took me awhile too to get JDBC to call these right.

  • Calling Stored Procedure from Oracle DataBase using Sender JDBC (JDBC-JMS)

    Hi All,
    We have requirement to move the data from Database to Queue (Interface Flow: JDBC -> JMS).
    Database is Oracle.
    *Based on Event, data will be triggered into two tables: XX & YY. This event occurs twice daily.
    Take one field: 'aa' in XX and compare it with the field: 'pp' in YY.
    If both are equal, then
         if the field: 'qq' in YY table equals to "Add" then take the data from the view table: 'Add_View'.
         else  if the field: 'qq' in YY table equals to "Modify"  then take the data from the view table: 'Modify_View'.
    Finally, We need to archive the selected data from the respective view table.*
    From each table, data will come differently, means with different field names.
    I thought of call Stored Procedure from Sender JDBC Adapter for the above requirement.
    But I heard that, we cannot call stored procedure in Oracle through Sender JDBC as it returns Cursor instead of ResultSet.
    Is there any way other than Stored Procedure?
    How to handle Data Types as data is coming from two different tables?
    Can we create one data type for two tables?
    Is BPM required for this to collect data from two different tables?
    Can somebody guide me on how to handle this?
    Waiting eagerly for help which will be rewarded.
    Thanks and Regards,
    Jyothirmayi.

    Hi Gopal,
    Thank you for your reply.
    >Is there any way other than Stored Procedure?
    Can you try configuring sender adapter to poll the data in intervals. You can configure Automatic TIme planning (ATP) in the sender jdbc channel.
    I need to select the data from different tables based on some conditions. Let me simplify that.
    Suppose Table1 contains 'n' no of rows. For each row, I need to test two conditions where only one condition will be satisfied. If 1st condition is satisfied, then data needs to be taken from Table2 else data needs to be taken from Table3.
    How can we meet this by configuring sender adapter with ATP?
    ================================================================================================
    >How to handle Data Types as data is coming from two different tables?
    If you use join query in the select statement field of the channel then whatever you need select fields will be returned. This might be fields of two tables. your datatype fields are combination of two diff table.
    we need to take data only from one table at a time. It is not join of two tables.
    ================================================================================================
    Thanks,
    Jyothirmayi.

  • Problems calling stored procedure with DG4IFMX

    Hi guys,
    I am trying to call stored procedures from Informix Database which is connected through Oracle Database Gateway for Informix.
    I have run select,update,delete successfully but when i try to run a stored procedure nothing happens.
    for example :
    when i run
    call "branko"@link_informix(1)
    it returns that it is successfully executed, without any error, but as u can see bellow no entry is entered in the branko_test table
    at informix :
    drop procedure branko;
    create procedure "informix".branko(_vlez integer)
    returning boolean;
    if _vlez = 1 then
    insert into branko_test values('test uspesen','1');
    else
    insert into branko_test values('test uspesen 2','2');
    end if;
    end procedure;
    the procedure runs ok when called from informix.
    Thank you for any help
    P.S i have even tried running:
    declare
    ret integer;
    begin
    ret := DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@link_informix('execute procedure branko(2)');
    end;
    but the same thing is happening, no entry in the table branko_test.

    Found the root cause:
    when using dbaccess to call the original procedure it reports on the screen (expression)
    => removing the return value as it is not handled
    -> looks like the unhandled return value boolean. Modifying the procedure to
    drop procedure branko;
    create procedure "informix".branko(_vlez integer)
    if _vlez = 1 then
    insert into branko_test values('test uspesen','1');
    else
    insert into branko_test values('test uspesen 2','2');
    end if;
    end procedure;
    allows me to execute the procedure using passthrough
    DECLARE
    result VARCHAR2(50);
    BEGIN
    result := DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@dg4ifmx('execute procedure informix.branko(1)');
    END;
    Edited by: kgronau on May 6, 2011 7:31 AM

  • Calling stored procedures with output parameters using RDO and VB

    I have a simple test procedure defined as follows:
    CREATE OR REPLACE PROCEDURE test_sp (inval1 IN VARCHAR2,
    inval2 IN NUMBER, inval3 OUT VARCHAR2, inval4 OUT NUMBER) IS
    BEGIN
    inval3 := 'RETURN TEST';
    inval4 := 10;
    END;
    I am attempting to call this procedure from VB 5.0 using RDO and the Oracle ODBC Driver 8.01.06:
    dim rdoQd as rdoQuery
    dim grdoCn as rdoConnection
    strSQL = "{ call test_sp('SOMETHING',?,?,?) }"
    Set rdoQd = grdoCn.CreateQuery("", strSQL)
    rdoQd(0).Direction = rdParamInput
    ' get error# 40041 at above line
    ' "Object Collection: Couldn't ' find item indicated by text."
    rdoQd(0).Type = rdTypeINTEGER
    rdoQd(0).Value = 5
    rdoQd(1).Direction = rdParamOutput
    rdoQd(1).Type = rdTypeVARCHAR
    rdoQd(2).Direction = rdParamOutput
    rdoQd(2).Type = rdTypeINTEGER
    Set rdoApp = rdoQd.OpenResultset()
    MsgBox (CStr(rdoQd(1)))
    MsgBox (CStr(rdoQd(2)))
    When I run this VB code, I get the above mentioned error. If I use placeholders for all parameters (like "{ call test_sp (?,?,?,?) }" ), no error occurs.
    I really need to use the first type of syntax from above and not have to use placeholders for all parameters. Is there a way to accomplish this?
    TIA,
    Esther

    Are you getting any warning while importing the stored procedure?
    Please check the below datatypes:
    While creating the stored procedure, if you have used varchar(MAX), please ALTER it to varchar(255) and reimport to DS.
    Also, the datatype of $message (global variable or local variable) used inside DS should also be varchar(255)
    Try a print statement in between.
    ADMIN.DBO.SPJOBSUMMARY(69,$message,$rtCode,$rtVal);
    print('Message is '||$message);
    smtp_to('leighattest.com.au', 'Results of ' || job_name(), $rtCode || '//' || $rtVal || '~~' || $message || '//', 0,0);
    and see in the job log if DS is able to retrieve the output from DB.
    Regards,
    Suneer

  • Problem call stored procedure from asp using oo4o

    I am having a problem calling a pl/sql stored procedure from ASP.
    Attached is the code. Any help would be appreciated. There are no errors returned on the page as far as I can tell.
    Sub add_cc_rec(p_location_rental_object_num, p_start_date, p_end_date, p_rate_code, p_quantity)
         'On Error Resume Next     
         Dim msg, stat, p_available, p_free_sell, p_cap_level, p_status_code, p_error_code
         Dim OraDatabase, PlSqlStmt
         Response.Write "In Function add_cc_rec<br>"
         msg = ""
         stat = ""
         p_available = "Y"
         p_free_sell = "Y"
         p_cap_level = "0"
         p_status_code = 2
         p_error_code = ""
         Set OraSession = Server.CreateObject("OracleInProcServer.XOraSession")
         Response.Write "Created OraSession<br>"
         Set OraDatabase = OraSession.OpenDatabase(ORADB, RUUID &"/"& RUPWD, 0)
         'Set OraDatabase = OraSession.DbOpenDatabase(ORADB, RUUID &"/"& RUPWD,cint(0))
         'Set OraDatabase = OraSession.DbOpenDatabase(ORADB, UID &"/"& PWD,cint(0))
         Response.Write "Created OraDatabase with the following parameters<br>"
         Response.Write "Database is " & ORADB & "<br>"
         Response.Write "UserId is " & RUUID & "<br><br>"
         OraDatabase.Parameters.Add "p_location_rental_object_num", p_location_rental_object_num, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_available", p_available, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_start_date", p_start_date, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_end_date", p_end_date, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_free_sell", p_free_sell, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_quantity", p_quantity, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_cap_level", p_cap_level, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_rate_code", p_rate_code, ORAPARM_INPUT, ORATYPE_VARCHAR2
         OraDatabase.Parameters.Add "p_status_code", p_status_code, ORAPARM_OUTPUT, ORATYPE_NUMBER
         OraDatabase.Parameters.Add "p_error_code", p_error_code, ORAPARM_OUTPUT, ORATYPE_VARCHAR2
         Response.Write "Calling PL/SQL procedure cc_insert <br>"
         Set PlSqlStmt = OraDatabase.CreateSQL("Begin RATELINK_CAPACITY_CONTROL.cc_insert(:p_location_rental_object_num, :p_available, :p_start_date, :p_end_date, :p_free_sell, :p_quantity, :p_cap_level, :p_rate_code, :p_status_code, :p_error_code); end;", ORASQL_DEFAULT)
         Response.Write "PL/SQL procedure cc_insert has been called <br>"
         Response.Write "Status code from PL/SQL procedure cc_insert (" & OraDatabase.Parameters("p_status_code").value & ")<br>"
         Response.Write "Error code from PL/SQL procedure cc_insert (" & OraDatabase.Parameters("p_error_code").value & ")<br>"
         'Response.Write "Error code from PL/SQL procedure cc_insert (" & p_error_code & ")<br>"
         OraDatabase.Parameters.Remove "p_location_rental_object_num"
         OraDatabase.Parameters.Remove "p_available"
         OraDatabase.Parameters.Remove "p_start_date"
         OraDatabase.Parameters.Remove "p_end_date"
         OraDatabase.Parameters.Remove "p_free_sell"
         OraDatabase.Parameters.Remove "p_quantity"
         OraDatabase.Parameters.Remove "p_cap_level"
         OraDatabase.Parameters.Remove "p_rate_code"
         OraDatabase.Parameters.Remove "p_status_code"
         OraDatabase.Parameters.Remove "p_error_code"
         Set OraSession = Nothing
         Set OraDatabase = Nothing
    End Sub

    1 - Can I clear errors on the OraDatabase class. How do
    I do that?They store the last error, should clear itself.
    2. Is this a client side or server side error? If this
    is a client side error, how do I resolve it?Server side error only. Make sure the user you connect as can see 'RATELINK_CAPACITY_CONTROL.CC_INSERT' and has execute permissions on it. You may need to qualify it with a schema name if the connected user is not the schema owner.

  • Problems calling stored procedure with out ref cursors

    Hi,
    I am calling an oracle stored procedure and having problems. This is the code:
    ResultSet cursor1, cursor2, cursor3, cursor4,cursor5,cursor6;
    String sql = "BEGIN SYSADM.PKG_SERVICE.SERV_MAIN(:1,:2,:3,:4,:5,:6,:7,:8,:9) \n; END;";
    CallableStatement call = null;
    try
    call = conn.prepareCall(sql);
    call.setString(1,blah1);
    call.setString(2,blah2);
    call.setString(3,blah3);
    call.registerOutParameter(4,OracleTypes.CURSOR);
    call.registerOutParameter(5,OracleTypes.CURSOR);
    call.registerOutParameter(6,OracleTypes.CURSOR);
    call.registerOutParameter(7,OracleTypes.CURSOR);
    call.registerOutParameter(8,OracleTypes.CURSOR);
    call.registerOutParameter(9,OracleTypes.CURSOR);
    call.execute();
    cursor1 = ((OracleCallableStatement) call).getCursor(4);
    cursor2 = ((OracleCallableStatement) call).getCursor(5);
    cursor3 = ((OracleCallableStatement) call).getCursor(6);
    cursor4 = ((OracleCallableStatement) call).getCursor(7);
    cursor5 = ((OracleCallableStatement) call).getCursor(8);
    cursor6 = ((OracleCallableStatement) call).getCursor(9);
    on the cursor1 = line I get this exception:
    06/08/08 15:07:01 java.lang.ClassCastException: com.evermind.sql.FilterCallableStatement
    this is a web service running in JDeveloper 10.1.2
    Dennis

    Dennis,
    There is only one "data-sources.xml" file in my JDeveloper 10.1.3. It is in the "\j2ee\home\config" subdirectory.
    But the again, I have not used my JDeveloper to create any Web services.
    I really think you should try the JDeveloper and ADF forum.
    Also, there are several debug properties you can set for OC4J.
    Since you say you are using 10.1.2, the following Web page may be helpful:
    http://www.oracle.com/technology/tech/java/oc4j/htdocs/oc4j-logging-debugging-technote.html
    Good Luck,
    Avi.

  • Problem calling stored procedure with user-defined type of input parameters

    Hi,
    I have to call a stored procedure with IN parameters, but these are user-defined types of input parameters.
    function fv_createnews (
    pit_groups in T_APPLICATION_USER_GROUPS,
    pit_documents in T_DOCUMENTS
    return varchar2;
    TYPE T_APPLICATION_USER_GROUPS IS
    TABLE OF varchar2(500)
    INDEX BY binary_integer;
    TYPE T_DOCUMENT IS record (
    name varchar2(256)
    ,url varchar2(1024)
    ,lang varchar2(30)
    ,foldername varchar2(150)
    TYPE T_DOCUMENTS IS
    TABLE OF T_DOCUMENT
    INDEX BY binary_integer;
    How can I do this using the TopLink 10.1.3 API.
    I already found following related posts, but I still can' t make it up:
    Using VARRAYs as parameters to a Stored Procedure
    Pass Object as In/Out Parameter in Stored Procedure
    Or do I have to create my own PreparedStatement for this special stored procedure call using Java and Toplink?

    As the related posts suggest, you will need to use direct JDBC code for this.
    Also I'm not sure JDBC supports the RECORD type, so you may need to wrap your stored functions with ones that either flatten the record out, or take OBJECT types.

  • PLSQL portlet - problem calling stored procedure -

    Good day folks. My portal version 10.1.2. I have a dynamic page with multiple rows. For simplicity, example here has two columns => id and value. The initial dilemma - The stored procedure specified in the action attribute of the <form> tag has to have parameters that match in name and count to the fields on the html form. But, the number of rows is variable on the form. I currently use pl/sql to generate the page. I have two forms in the html - form A has two static fields id and value, with an action attribute of the stored procedure I want to run. The second html form is form B. It has id_1, value_1, id_2, value_2, id_3, value_3 and so on with a variable number of rows. SO, when the user clicks the "Submit" button at the bnottom of the page, I call a javascript passing in the number of rows. I then loop through the Form B, and for each row of data, I do a submit of Form A. My goal is to run the stored procedure in the database for each row of data in Form B. I use Form A to accomodate the requirement that the stored procedure has to match in name and number the parameters inthe form.
    This is to avoid an update button on each row of data, also.
    The problem - in my javascript, I set the values of Form A to the values from Form B correctly. However, only the last rowis successful in running the procedure. For example, if I have 3 rows in Form B, I want to submit form A 3 times, but, it only seems to submit once for row #3. The weird thing is if I put an alert message after the document.formA.submit(); command, the stored procedure is successfully called for each row in form B, but when I remove the alert, only the last row successfully calls the procedure!
    Thanks in advance if anybody has any ideas -
    Kent

    Let's continue the example of 3 rows.
    It sounds like that you submit the form 3 times in quick succession, and so before the Action for Form A has had time to run and respond for the first row, the second row has been submitted, and therefore the web page will stop trying to display the results from the submit of Row 1 (by this I mean it'll stop the http request, if you do this quick enough then the back-end function won't run). Then the same thing happens to Row 2's submit when Row 3 starts.
    What it sounds like you need to do is to use only 2 parameters, but repeat them on the HTML page, when the submit is run it's passed to oracle as a type 'owa_util.vc_arr'. There is a more comprehensive solution to this problem in another thread:
    passing variable number of arguments in a stored procedure
    Please note though that you have to be careful of the situations where your form only has one row to submit to the oracle function, in this case the data type of the parameter will be a VARCHAR2 rather than a owa_util.vc_arr. The solution to this problem is to always have a an extra dummy parameter which is empty and you skip over it during your processing. (Thought I'd better include this information in case you ran into this problem).
    Hope this helps.
    Cheers,
    Ron.

  • Calling stored procedure returning result set

    Hi all,
    i know this issue is discussed quite often. I did not find an answer in the forums, not in the manual and even not in the examples for stored procedure.
    So i try it here once more :)
    Description:
    GET_SKS:
    The GET_SKS procedure is used to generate a number of surrogate keys. It has one input parameter NUM_SKS_IN that specifies the number of keys to generate. The generated keys are returned as a result set.
    So i tried:
    CallableStatemant sproc_stmt = lsession.connection().prepareCall("{ call Get_SKS(?,?)}");
    sproc_stmt.setInt(2,1);
    sproc_stmt.registerOutParameter(1,OracleTypes.CURSOR);
    sproc_stmt.execute();
    ResultSet sproc_result = (ResultSet) sproc_stmt.getObject(1);
    I got the exception:
    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'GET_SKS'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Thanks for help! This is really getting frustrating...
    Regards,
    ak

    Hi there,
    i could speak to our one of our admins. This is what he gave me:
    CREATE OR REPLACE PROCEDURE "TCSDBOWNER"."GET_SKS"
       (num_sks_in IN INTEGER,
        sk_out OUT SYS_INFO.SYS_INFO_SK%TYPE)
    AS
    /*+
    || Procedure - GET_SKS - Oracle
    ||
    || Description:
    ||   This procedure is used to get one or more primary keys for tables with
    ||   surrogate keys as the primary key.  This number is unique across all
    ||   tables and installations for a given client.
    ||
    || Parameters:
    ||   num_sks_in - INTEGER: number of surrogate keys to return
    ||   sk_out - sk_subtype: first key in the sequence of requested keys
    ||
    || History:
    ||   08/30/01,dcs: Created
      CURSOR request_cur IS
        select DBMS_LOCK.REQUEST(170333184) from dual;
      CURSOR release_cur IS
        select DBMS_LOCK.RELEASE(170333184) from dual;
      CURSOR dual_sk_cur IS
         select SEQ_SK.NEXTVAL SK
           from DUAL;
      v_base_offset SYS_INFO.BASE_OFFSET%TYPE;
      v_sk SYS_INFO.SYS_INFO_SK%TYPE;
      v_sqlstring VARCHAR2(1000);
      v_cursor_handle INTEGER;
      v_return INTEGER;
    BEGIN
      IF num_sks_in < 1 THEN
        TCS_EXC.RAISE_ERROR(TCS_EXC.num_sks_in_lt_1);
      END IF;
      OPEN request_cur;
      FETCH request_cur INTO v_return;
      CLOSE request_cur;
      IF v_return <> 0 AND v_return <> 4 THEN
        TCS_EXC.RAISE_ERROR(TCS_EXC.sk_gen_lock_failed);
      END IF;
      v_cursor_handle := DBMS_SQL.OPEN_CURSOR;
      v_sqlstring := 'ALTER SEQUENCE SEQ_SK INCREMENT BY '|| TO_CHAR(num_sks_in);
      DBMS_SQL.PARSE(v_cursor_handle, v_sqlstring, DBMS_SQL.V7);
      v_return := DBMS_SQL.EXECUTE(v_cursor_handle);
      DBMS_SQL.CLOSE_CURSOR(v_cursor_handle);
      GET_BASE_OFFSET(v_base_offset);
      OPEN dual_sk_cur;
      FETCH dual_sk_cur INTO v_sk;
      CLOSE dual_sk_cur;
      sk_out := (v_base_offset * 10000000000) + v_sk - num_sks_in + 1;
      v_cursor_handle := DBMS_SQL.OPEN_CURSOR;
      v_sqlstring := 'ALTER SEQUENCE SEQ_SK INCREMENT BY 1';
      DBMS_SQL.PARSE(v_cursor_handle, v_sqlstring, DBMS_SQL.V7);
      v_return := DBMS_SQL.EXECUTE(v_cursor_handle);
      DBMS_SQL.CLOSE_CURSOR(v_cursor_handle);
      OPEN release_cur;
      FETCH release_cur INTO v_return;
      CLOSE release_cur;
      IF v_return <> 0 THEN
        TCS_EXC.RAISE_ERROR(TCS_EXC.sk_gen_lock_failed);
      END IF;
    END GET_SKS; Ok, i tried with that but even not succeded yet. Can anybody help me to code that into a java call?
    Regards,
    ak

  • Call stored procedure

    Hi:
    I have a customer that wants to eliminate direct queries to enterprise databases and invoke stored procedures. This will ease maintenance issues down the line if underlying schema is changed. At any rate the Call Stored Procedure returns the number of rows affected by the call, not the result set(s).  I'm hoping I&apos;m missing something in the docs. There has to be a way to execute a stored procedure that returns the result sets.

    You're not missing anything. The current implementation of the stored procedure can only return the number of rows affected. They are looking at fixing that in the next release.
    The alternative is to use the Execute Script service and use jdbc code to execute your stored procedure. See http://forums.adobe.com/message/2302938#2302938 for an example.
    Jasmin

  • Problem with stored procedure usage when Toplink api is used

    In one of our applications we used the combination of JBoss4.0.2 application server, Oracle Toplink 10g (9.0.4.5), JDBC Driver Version is ..... 10.1.0.2.0, Database Product Version is Oracle9i Enterprise Edition Release 9.2.0.6.0, j2sdk1.4.2_08
    We faced problem in the application when it is trying to call stored procedure using Oracle Toplink api
    code snippet:
    public ByteArrayOutputStream baos = new ByteArrayOutputStream();
    public PrintStream pos = new PrintStream(baos);
    public String delete(String Id)
    String procedureName = "abc";
    try
    UnitOfWork uow = PersistenceManager.getCurrent().getUnitOfWork();
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName(procedureName);
    call.addUnamedArgumentValue(Id);
    uow.executeNonSelectingCall(call);
    uow.commit();
    catch (Exception e)
    message = e;
    e.printStackTrace(pos);
    message = message+ baos.toString();
    return message;
    Stack Trace:
    Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle.toplink.exceptions.DatabaseException Exception Description: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'abc' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'abc' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Error Code: 6550Local Exception Stack: Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle.toplink.exceptions.DatabaseException Exception Description: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'abc' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00201: identifier 'DELETE_LOADED_RESULT_SET' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored Error Code: 6550 at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:227) at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:733) at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:781) at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:642) at oracle.toplink.publicinterface.UnitOfWork.executeCall(UnitOfWork.java:1400) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:131) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:115) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeNoSelectCall(CallQueryMechanism.java:164) at oracle.toplink.internal.queryframework.CallQueryMechanism.executeNoSelect(CallQueryMechanism.java:143) at oracle.toplink.queryframework.DataModifyQuery.execute(DataModifyQuery.java:41) at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:493) at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1958) at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2236) at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086) at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1038) at oracle.toplink.publicinterface.Session.executeNonSelectingCall(Session.java:816) at com.abc.de.fg.model.resultSet.ResultSetProvider.delete(ResultSetProvider.java:150) at
    Could anyone please let me know what might be the problem in this case.

    Tried and couldn't reproduce the problem using 9.0.4.7.
    Here's the code:
        System.out.println("storedProcedureUnamedValueTest");
        StoredProcedureCall call = new StoredProcedureCall();
        String lastName = "Jones";
        call.setProcedureName("STOREDPROCEDURE_IN");
        call.addUnamedArgumentValue(lastName);
        session.executeNonSelectingCall(call);stored procedure definition in data base:
    CREATE OR REPLACE  PROCEDURE "TEST_904"."STOREDPROCEDURE_IN"  (
         IN_PARAM VARCHAR2) AS
    BEGIN
      UPDATE EMPLOYEE SET F_NAME = 'Indiana' WHERE (L_NAME = IN_PARAM);
    END;log:
    storedProcedureUnamedValueTest
    DatabaseSession(15)--Execute query DataModifyQuery()
    DatabaseSession(15)--Connection(16)--BEGIN STOREDPROCEDURE_IN('Jones'); END;
    DatabaseSession(15)--Connection(16)--reconnecting to external connection poolAndrei

  • Calling Stored Procedure which returns single or multiple value

    Hi All Experts,
    I have written one stored procedure which is returning different
    integer values according to condition.I am calling this
    stored procedure through prepareCall() method then executeUpdate() method ,but it is always returning 1,not my desired value.
    Pl also tell me,if my stored procedure returns more than one value
    then how will i get those values in my java program?
    Pl help by writing some sample code.
    Thanx in Advance.
    Pradipto

    1) Create CallableStatement
    2) For each of returning value you have to call RegisterOutParameter()
    3) For others user setXXX() method depending on type of parameter
    4) call
    5) use vars registered through RegisterOutParameter() - all your values should be there
    Pavel

  • How to use @jws:sql call Stored Procedure from Workshop

    Is there anyone know how to use @jws tag call Sybase stored procedure within
    Workshop,
    Thanks,

    Anurag,
    Do you know is there any plan to add this feature in future release? and
    when?
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    In the current release, we do not support calling stored procedures from a
    database control. You will have to write JDBC code in the JWS file to call
    stored procedures.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Anurag,
    I know how to use DB connection pool and create a db control with it. In
    fact, we have created a Web Service with the db control using plain SQL
    in
    @jws:sql. However, my question here is how to use @jws tag in Weblogic
    Workshop to create a Web Services based on Sybase stored procedure orany
    Stored Proc not plain SQL.
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    You can use a database control to obtain a connection from any JDBC
    Connection Pool configured in the config.xml file. The JDBC Connectionpool
    could be connecting to any database, the database control is
    independent
    of
    that.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Is there anyone know how to use @jws tag call Sybase stored
    procedure
    within
    Workshop,
    Thanks,

Maybe you are looking for