Calling stored proc through JDBC

Hello all,
What I am doing is calling a stored proceedure in this manner...
CallableStatement stmt = dbB.getConn().prepareCall ("call LDPKG.LDGetData(?, ?)");  //dbB is a conn Class I made, it works fine and getConn obviously jsut returns teh Connection object... Those work fine disreguard them.
stmt.registerOutParameter(1, <IDONTKNOW>);  //I dont know the return type
stmt.registerOutParameter(2, <IDONTKNOW>);  //I dont know the return type
stmt.execute();I am unsure of what to put for the return type... The DB has these TYPES created as teh OUT for the stored Proc ...
TYPE t_returnId is table of LDDATA.UserId%TYPE index by BINARY_INTEGER
TYPE t_returnName is table of LDDATA.UserName%TYPE index by BINARY_INTEGER
I dont know how to translate that return type to Java... Any ideas???
Thanks!

If you want the whole thing it is like this... I just didnt see the point in being redundant with the output types. Now that Date is an issue I brought it up. didnt think i needed to before.. sorry.
OracleCallableStatement stmt = (OracleCallableStatement)dbB.getConn().prepareCall ("begin LDPKG.LDGetData(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); end;");
stmt.registerIndexTableOutParameter(1,500, OracleTypes.NUMBER, 0);
stmt.registerIndexTableOutParameter(2,500, OracleTypes.DATE, 0);
stmt.registerIndexTableOutParameter(3,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(4,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(5,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(6,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(7,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(8,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(9,500, OracleTypes.NUMBER, 0);
stmt.registerIndexTableOutParameter(10,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(11,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(12,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(13,500, OracleTypes.VARCHAR, 0);
stmt.registerIndexTableOutParameter(14,500, OracleTypes.VARCHAR, 0);
stmt.execute();I'm still looking through Google but not finding much about this :(.

Similar Messages

  • How to Call Stored Proc. through JDBC from SQL Server

    I have to call Stored Procedure by JDBC in java. This is the prog i m using:
    import java.sql.*;
    import java.io.*;
    class callSP
    public static void main(String a[]) throws Exception
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection c=DriverManager.getConnection("jdbc:odbc:first","sa","");
    //CallableStatement cs=c.prepareCall("{? =call GET_CLUSTER(?)}");
    CallableStatement cs=c.prepareCall("{call GET_CLUSTER(?)}");
    cs.registerOutParameter(1,Types.CHAR);
    //cs.setString(1, "Teamwork");
    cs.execute();
    //cs.executeUpdate();
    String output=cs.getString(1);
    System.out.println(output);
    catch (SQLException e)
    System.out.println(e);
    This is the Stored Procedure:
    CREATE PROCEDURE GET_CLUSTER
    @Ip_THESAURUS_KEY_WORD CHAR(40)
    AS
    DECLARE @Lc_THESAURUS_CODE INT,
    @Lc_CLUSTER_CODE INT
    BEGIN
    --GET THE THESARUS CODE FOR THE KEYWORD
    SELECT @Lc_THESAURUS_CODE = THESAURUS_CODE
    FROM THESAURUS_LIST
    WHERE THESAURUS_KEY_WORD = @Ip_THESAURUS_KEY_WORD
    --GETTING THE CLUSTER ID
    SELECT @Lc_CLUSTER_CODE = CLUSTER_CODE
    FROM THESAURUS_ENRICH_CLUSTER
    WHERE THESAURUS_CODE = @Lc_THESAURUS_CODE
    --GET THE CLUSTER KEYWORDS
    SELECT THESAURUS_KEY_WORD
    FROM THESAURUS_LIST T,THESAURUS_ENRICH_CLUSTER C
    WHERE T.THESAURUS_CODE=C.THESAURUS_CODE
    AND C.CLUSTER_CODE=@Lc_CLUSTER_CODE AND NOT THESAURUS_KEY_WORD=@Ip_THESAURUS_KEY_WORD
    END
    GO
    Check it out what is problem. Data is not getting, it is giving exception.

    Please be specific regarding the problem that you are facing, that's the key to getting help in the forum. If there's exception in your program, such as NullPointerException or SQLException, please state it in your post.

  • Calling Stored Procedures through JDBC

    Hello!
    I would like to implement a call to a stored procedure through JDBC. This call I suppose to embed in JavaBean to import Bean as model.
      A) Shoud this call be implemented inside ordinaly JavaBean or inside EJB?
      B) How can I determine DataSource? Is it possible through JNDI?
      C) Is there any tutorials or examples?
      D) Could anybody give some code texts on this theme?

    we use quite a similar architecture here (2 ORACLE DBs, a DB link from one instance to the other). However, we use the db links in functions (not in stored procedures). but a simple select using the db link also works with JDBC. do you use the very same db instances / schemas / users+passwords on all your different test environments? so far, we havent' noticed any problems with ORACLE queries (stored procedures, functions, etc.) that work in sqlplus/worksheet but not with JDBC. do you use the latest ORACLE JDBC drivers (9.2.0.3)?

  • Calling Stored Proc from JDBC

    Hi All,
    I have a simple stored proc in SQL server 2000
    CREATE PROCEDURE dbo.sp_myProc
    AS
    SELECT CategoryID,CategoryName from Categories
    GO
    My java code is
    CallableStatement cs = connection.prepareCall("{? = call sp_myProc}");
    cs.registerOutParameter(1, Types.VARCHAR);
    boolean result = cs.execute();
    System.out.println("Result : "+result);
    ResultSet rs = (ResultSet)cs.getResultSet();
    while(rs.next())
    System.out.println(rs.getString("CategoryID"));
    When I execute this, the stored procedure gets executed succesfully i.e, the Result is true.
    But the resultset object : rs is Null. It returns a null pointer exception at rs.next();
    The table has values & this returns proper values in SQL analyzer.
    I use Microsoft JDBC drivers for SQL server.
    Is there anything I am doing wrong, all examples i saw refered to the same thing. I am struck with this any help would be appreciated.
    Thanks in advance,
    Sudhindra

    Sorry - small mistake here.
    The number of ? marks in the () brackets = the number of parameters in the procedure.
    Thus with your procedure nothing gets returned.
    With an Oracle Db you will declare the proc as follows:
    PROCEDURE abcd (par1 IN OUT VARCHAR2, par2 IN OUT VARCHAR2)
    IS
    BEGIN
    SELECT abc, def INTO par1, par2 FROM xyz;
    END;
    Thus you will register two in String parameters AND two out String parameters.
    If you require more than one record to be returned the you need to have a look at some collection type to be returned other than VARCHAR2.
    Andre

  • 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);

  • 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

  • SQL Exception: Invalid column index while calling stored proc from CO.java

    Hello all,
    I am getting a "SQL Exception: Invalid column index" error while calling stored proc from CO.java
    # I am trying to call this proc from controller instead of AM
    # PL/SQL Proc has 4 IN params and 1 Out param.
    Code I am using is pasted below
    ==============================================
              OAApplicationModule am = (OAApplicationModule)oapagecontext.getApplicationModule(oawebbean);
    OADBTransaction txn = (OADBTransaction)am.getOADBTransaction();
    OracleCallableStatement cs = null;
    cs = (OracleCallableStatement)txn.createCallableStatement("begin MY_PACKAGE.SEND_EMAIL_ON_PASSWORD_CHANGE(:1, :2, :3, :4, :5); end;", 1);
         try
    cs.registerOutParameter(5, Types.VARCHAR, 0, 2000);
                        cs.setString(1, "[email protected]");
                             cs.setString(2, s10);
    //Debug
    System.out.println(s10);
                             cs.setString (3, "p_subject " );
                             cs.setString (4, "clob_html_message - WPTEST" );
                   outParamValue = cs.getString(1);
    cs.executeQuery();
    txn.commit();
    catch(SQLException ex)
    throw new OAException("SQL Exception: "+ex.getMessage());
    =========================================
    Can you help please.
    Thanks,
    Vinod

    You may refer below URL
    http://oracleanil.blogspot.com/2009/04/itemqueryvoxml.html
    Thanks
    AJ

  • Problem Obtaining multiple results from MySql Stored Proc via JDBC

    I've spent alot of time on this and I'd be really grateful for anyones help please!
    I have written a java class to execute a MySQL stored procedure that does an UPDATE and then a SELECT. I want to handle the resultset from the SELECT AND get a count of the number of rows updated by the UPDATE. Even though several rows get updated by the stored proc, getUpdateCount() returns zero.
    It's like following the UPDATE with a SELECT causes the updatecount info to be lost. I tried it in reverse: SELECT first and UPDATE last and it works properly. I can get the resultset and the updatecount.
    My Stored Procedure:
    delimiter $$ CREATE PROCEDURE multiRS( IN drugId int, IN drugPrice decimal(8,2) ) BEGIN UPDATE drugs SET DRUG_PRICE = drugPrice WHERE DRUG_ID > drugId; SELECT DRUG_ID, DRUG_NAME, DRUG_PRICE FROM Drugs where DRUG_ID > 7 ORDER BY DRUG_ID ASC; END $$
    In my program (below) callablestatement.execute() returns TRUE even though the first thing I do in my stored proc is an UPDATE not a SELECT. Is this at odds with the JDBC 2 API? Shouldn't it return false since the first "result" returned is NOT a resultset but an updatecount? Does JDBC return any resultsets first by default, even if INSERTS, UPDATES happened in the stored proc before the SELECTs??
    Excerpt of my Java Class:
    // Create CallableStatement CallableStatement cs = con.prepareCall("CALL multiRS(?,?)"); // Register input parameters ........ // Execute the Stored Proc boolean getResultSetNow = cs.execute(); int updateCount = -1; System.out.println("getResultSetNow: " +getResultSetNow); while (true) { if (getResultSetNow) { ResultSet rs = cs.getResultSet(); while (rs.next()) { // fully process result set before calling getMoreResults() again! System.out.println(rs.getInt("DRUG_ID") +", "+rs.getString("DRUG_NAME") +", "+rs.getBigDecimal("DRUG_PRICE")); } rs.close(); } else { updateCount = cs.getUpdateCount(); if (updateCount != -1) { // it's a valid update count System.out.println("Reporting an update count of " +updateCount); } } if ((!getResultSetNow) && (updateCount == -1)) break; // done with loop, finished all the returns getResultSetNow = cs.getMoreResults(); }
    The output of running the program at command line:
    getResultSetNow: true 28, Apple, 127.00 35, Orange, 127.00 36, Bananna, 127.00 37, Berry, 127.00 Reporting an update count of 0
    During my testing I have noticed:
    1. According to the Java documentation execute() returns true if the first result is a ResultSet object; false if the first result is an update count or there is no result. In my java class callablestatement.execute() will return TRUE if in the stored proc the UPDATE is done first and then the SELECT last or vica versa.
    2. My java class (above) is coded to loop through all results returned from the stored proc in succession. Running this class shows that any resultsets are returned first and then update counts last regardless of the order in which they appear in the stored proc. Maybe there is nothing unusual here, it may be that Java is designed to return any Resultsets first by default even if they didn't happen first in the stored procedure?
    3. In my stored procedure, if the UPDATE happens last then callablestatement.getUpdateCount() will return the correct number of updated rows.
    4. If the UPDATE is followed by a SELECT (see above) then callablestatement.getUpdateCount() will return ZERO even though rows were updated.
    5. I tested it with the stored proc doing SELECT - UPDATE - SELECT and again getUpdateCount() returns ZERO.
    6. I tested it with the stored proc doing SELECT - UPDATE - SELECT - UPDATE and this time getUpdateCount() returns the number rows updated by the last UPDATE and not the first.
    My Setup:
    Mac OS X 10.3.9
    Java 1.4.2
    mysql database 5.0.19
    mysql-connector 5.1.10 (connector/J)
    Maybe I have exposed a bug in JDBC?
    Thanks for your help.

    plica10 wrote:
    Jschell thank you for your response.
    I certainly don't mean to be rude but I often get taken that way. I like to state facts as I see them. I'd love to be proved wrong because then I would understand why my code doesn't work!
    Doesn't matter to me if you are rude or not. Rudeness actually makes it more entertaining for me so that is a plus. Nothing I have seen suggests rudeness.
    In response to your post:
    When a MySql stored procedure has multiple sql statements such as SELECT and UPDATE these statements each produce what the Java API documentation refers to as 'results'. A Java class can cycle through these 'results' using callableStatement dot getMoreResults(), getResultSet() and getUpdateCount() to retrieve the resultset object produced by Select queries and updateCount produced by Inserts, Deletes and Updates.
    As I read your question it seems to me that you have already proven that it does not in fact do that?
    You don't have to read this but in case you think I'm mistaken, there is more detail in the following website under the heading 'Using the Method execute':
    http://docsrv.sco.com/JDK_guide/jdbc/getstart/statement.doc.html#1000107
    Sounds reasonable. But does not your example code prove that this is not what happens for the database and driver that you are using?
    Myself I dont trust update counts at all since, in my experience some databases do not return them. And per other reports sometimes they don't return the correct value either.
    So there are two possibilities - your code is wrong or the driver/database does not do it. For me I would also question whether in the future the driver/database would continue to behave the same if you did find some special way to write your SQL so it does do it. And of course you would also need to insure that every proc that needed this would be written in this special way. Hopefully not too many of those.
    So this functionality is built into java but is not in common use amongst programmers. My java class did successfully execute a stored proc which Selected from and then finally Updated a table. My code displayed the contents of the Select query and told me how many rows were affected by the update.
    It isn't "built into java". It isn't built into jdbc either. If it works at all then the driver and by proxy the database are responsible for it. I suspect that you would be hard pressed to find anything in the JDBC spec that requires what that particular link claims. I believe it is difficult to find anything that suggests that update counts in any form are required.
    So you are left with hoping that a particular driver does do it.
    I suppose it is rare that you would want to do things this way. Returning rowcounts in OUT parameters would be easier but I want my code to be modular enough to cover the situation where a statement may return more than one ResultSet object, more than one update count, or a combination of ResultSet objects and update counts. The sql may need to be generated dynamically, its statements may be unknown at compile time. For instance a user might have a form that allows them to build their own queries...
    Any time I see statements like that it usually makes me a bit uncomfortable. If I am creating data layers I either use an existing framework or I generate the code. For the latter there is no generalization of the usage. Every single operation is laid out in its own code.
    And I have in fact created generalized frameworks in the past before. I won't do it again. Benefits of the other idioms during maintenance are too obvious.

  • ** How to use TO_DATE function in Stored Proc. for JDBC in ABAP-XSL mapping

    Hi friends,
    I use ABAP-XSL mapping to insert records in Oracle table. My Sender is File and receiver is JDBC. We use Oracle 10g database. All fields in table are VARCHAR2 except one field; this is having type 'DATE'.
    I use Stored procedure to update the records in table. I have converted my string into date using the Oracle TO_DATE function. But, when I use this format, it throws an error in the Receiver CC. (But, the message is processed successfully in SXMB_MONI).
    The input format I formed like below:
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">
    Value in Payload is like below.
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">TO_DATE('18-11-1991','DD-MM-YYYY')</X_EMP_START_DT>
    Error in CC comes as below:
    Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_EMP_DETAILS' (structure 'STATEMENT'): java.lang.NumberFormatException: For input string: "TO_DATE('18"
    Friends, I have tried, but unable to find the correct solution to insert.
    Kindly help me to solve this issue.
    Kind Regards,
    Jegathees P.
    (But, the same is working fine if we use direct method in ABAP-XSL ie. not thru Stored Procedure)

    Hi Sinha,
    Thanks for your reply.
    I used the syntax
    <xsl:call-template name="date:format-date">
       <xsl:with-param name="date-time" select="string" />
       <xsl:with-param name="pattern" select="string" />
    </xsl:call-template>
    in my Abap XSL.  But, its not working correctly. The problem is 'href' function to import "date.xsl" in my XSLT is not able to do that. The system throws an error. Moreover, it is not able to write the command 'extension-element-prefixes' in my <xsl:stylesheet namespace>
    May be I am not able to understand how to use this.
    Anyway, I solved this problem by handling date conversion inside Oracle Stored Procedure. Now, its working fine.
    Thank you.

  • Calling stored proc from java using ref cursor

    Hi All,
    We have a requirement to display all the records from a table on a JAVA screen. Due to some constraints, we have to write the query in the stored proc. We are trying to return a result set from the stored proc to the java code by using a ref cursor. Please refer to the code below.
    Following is the PL/SQL proc �
    procedure sp_user_course2(v1 OUT ref_cursor, persid in varchar2) as
    begin
    open v1 for
    SELECT lrn_exp_id, crs_name FROM emp_crs
    WHERE personid = persid;
    end;
    Here ref_cursor is of TYPE REF CURSOR declared in the package specification.
    The java code is �
    Callable stmt = conn.prepareCall("call sp_user_course2(?,?)");
    stmt.registerOutParameter(1,OracleTypes.CURSOR);
    stmt.setString(2,emplId);
    stmt.execute();
    OracleCallableStatement tstmt = (OracleCallableStatement) stmt;
    ResultSet rs = tstmt.getCursor (1);
    When I run the program, I get the following error (at stmt.execute()):
    [Oracle][ODBC][Ora]ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_USER_COURSE2' 6553
    Can anyone tell me what could be the problem with this code? I have read somewhere that REF CURSOR feature is available from Oracle 9i onwards. If so, then, is there any workaround for mapping REF CURSOR to Resultsets in Oracle 8i?

    These may help
    http://www.google.co.uk/search?q=jdbc+OracleTypes.CURSOR+tutorial

  • Calling stored proc from java to return ref cursor

    Hi All,
    We have a requirement to display all the records from a table on a JAVA screen. Due to some constraints, we have to write the query in the stored proc. We are trying to return a result set from the stored proc to the java code by using a ref cursor. Please refer to the code below.
    Following is the PL/SQL proc ?
    procedure sp_user_course2(v1 OUT ref_cursor, persid in varchar2) as
    begin
    open v1 for
    SELECT lrn_exp_id, crs_name FROM emp_crs
    WHERE personid = persid;
    end;
    Here ref_cursor is of TYPE REF CURSOR declared in the package specification.
    The java code is ?
    Callable stmt = conn.prepareCall("call sp_user_course2(?,?)");
    stmt.registerOutParameter(1,OracleTypes.CURSOR);
    stmt.setString(2,emplId);
    stmt.execute();
    OracleCallableStatement tstmt = (OracleCallableStatement) stmt;
    ResultSet rs = tstmt.getCursor (1);
    When I run the program, I get the following error (at stmt.execute()):
    [Oracle][ODBC][Ora]ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_USER_COURSE2' 6553
    Can anyone tell me what could be the problem with this code? I have read somewhere that REF CURSOR feature is available from Oracle 9i onwards. If so, then, is there any workaround for mapping REF CURSOR to Resultsets in Oracle 8i?

    These may help
    http://www.google.co.uk/search?q=jdbc+OracleTypes.CURSOR+tutorial

  • Use 'default' keyword in call string while calling stored proc?

    I am calling following sql server stored procedure from java code using my jdbc driver for sql server: CREATE PROCEDURE test_findTbInfo (
    @paramIn_Str varchar(10),
    @paramOut_Int int OUT,
    @paramIn_Int int = 20
    AS
    begin
    set @paramOut_Int = @paramIn_Int * 100
    end
    If I make a call like this:
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , , ? ) }");
    cs.setString(1, "test_tab");
    cs.setInt(2, 4);
    cs.execute();
    It works without any error. But this is not a right behavior. !! The second parameter as you see is passed like an optional parameter. But in stored proc it is NOT an optional param and so if the value not passed it should fail...
    Now if I change the code to
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(? , default, ? ) }");
    it works correctly. Gives error that "Procedure 'test_findTbInfo' expects parameter '@paramOut_Int', which was not supplied." which is correct.
    So is it a normal practice to use 'default' keyword while calling sql server stored procedures having optional parameters in jdbc ????
    Anyone knows ??? As far as I know "call test_findTbInfo(? , , ? )" works fine except in some cases and also it forces users to put all optional parameters at the end of parameter list in stored proc.
    Please let me know whether I should go with 'default' throuout for sql server stored proc while calling using my jdbc driver.
    Amit

    {?= call <procedure-name>[<arg1>,<arg2>, ...]}The question mark in the above is the result parameter
    that must be registered.
    That is not the same as an OUT argument.Yes that is true. The result value and OUT parameters are different but they both MUST be registered as per jdbc API
    "The type of all OUT parameters must be registered prior to executing the stored procedure; their values are retrieved after execution via the get methods provided here."
    Anyway, my original question still stays as it was. If there are some optional IN parameters in stored procedure
    e.g.
    PROCEDURE test_findTbInfo (
    @paramIn_Int int = 20,
    @paramOut_Int int OUT
    how do you call this?
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo( , ? ) }");
    cs.registerOutParameter(1, Types.INTEGER);
    cs.execute();
    or
    CallableStatement cs = conn.prepareCall(" { call test_findTbInfo(default, ? ) }");
    Also note that I am intending to use ONLY sql server driver for this.
    The first as well second seem to work. Except that second way is seems reliable. I just wanted a second opinion on that...
    Amit

  • Calling stored proc via services

    I would be grateful if you could help me in resolving a technical issue in CMS(stellent).
    We have a requirement that we need to call a stored procedure through services .The stored proc takes an input argument and returns a result set and has a defination that starts like
    create or replace
    PACKAGE BODY GETPROJECTPCKG IS
    PROCEDURE PROC_RPU (rpu_list_count IN number, temp_project_cursor OUT project_ref_cursor) IS.
    I've defined a service call like
    <tr>
         <td>GET_RPU_INFO</td>
         <td>DocService
              33
              RECENTPROJECTUPDATE
              null
              null<br>
              null</td>
         <td>5:QgetRpuNames:temp_project_cursor::null</td>
    </tr>
    And below is how I've called the procedure
    <tr>
         <td>QgetRpuNames</td>
         <td>{call GETPROJECTPCKG.PROC_RPU(?)}</td>
         <td>rpu_list_count int</td>
    </tr>
    i tried calling procedure as below also ..
    <tr>
         <td>QgetRpuNames</td>
         <td>{call GETPROJECTPCKG.PROC_RPU(?,?)}</td>
         <td>rpu_list_count int
         temp_project_cursor out:resultset</td>
    </tr>
    As per my understanding the temp_project_cursor which is the resultset that would be returned from procedure should be available on the template specified.
    But while executing the service I am getting an error :
    Unable to create result set for query 'QgetRpuNames({call GETPROJECTPCKG.PROC_RPU(10)})'. ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PROC_RPU'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored)
    Can you please assist.

    Hey
    if this is still an issue please refert "Call Stored Procedure from Oracle Fusion ECM (Stellent) " at http://www.corecontentonly.com/index.php/downloads/. Jason has shared a component that you can make use of.
    cheers,
    sapan

  • Calling Stored Procedure without JDBC-Adapter

    Hallo,
    as it is not possible calling Stored Procedures with the parameter Typ Record in Oracle my question: It is possible connecting to DB using native java-code for example in Mapping?
    Thanks in advance,
    Frank

    Hi Frank,
    Maybe you can use the DB look up using the JDBC adapter in your mapping.
    Just check this blog for the same,
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    As for calling an Oracle Strored Procedure, it is possible using a RECEIVER JDBC adapter, but not a SENDER JDBC adapter.
    <i> import the jdbc-driver (oracle) in an archive in Designer.</i>
    Also, this imported archive should be under any Namespace, but, it should be in the same SWCV as the one in which the mapping is being executed.
    Regards,
    Bhavesh

  • Calling stored proc (with 2 IN and 3 OUT) - from SQL Plus

    This is the signature of my stored proc:
    CREATE OR REPLACE PROCEDURE myschema.myproc
       p_usr_name     IN  VARCHAR2,    
       p_send_tmstmp  IN  DATE,    
       p_ret_value    OUT NUMBER,
       p_err_code     OUT VARCHAR2
    )If I need to call it from sql plus, how do I need to pass the arg?
    This is what I am doing
    execute myschema.myproc('abc123','02-MAY-2008');
    What is wrong here? If someone could help. Thx!

    Try something like this
    var usr_name    varchar2(30)  
    var send_tmstmp varchar2(11)  
    var ret_value   number
    var err_code    varchar2(10)
    begin
    :usr_name    := 'abc123';
    :usr_name := '02-MAY-2008';
    myschema.myproc ( p_usr_name           => :usr_name,
                      p_send_tmstmp        => TO_DATE( :usr_name, 'DD-MON-YYYY' ),
                      p_ret_value          => :ret_value,
                      p_err_code           => :err_code);
    end;
    print ret_value;
    print err_code;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Merging multiple rows in to a single row (when rows meet merging criteria)

    Hi  I have a scenario to merge multiple rows in to a single rows when the data in those rows fall in merge criteria .Below is how my data is  Now the merging logic for the above rows is , we need to combine multiple rows in to a single row when the d

  • Samsung Monitor acting strange when connected with digital cable.

    I have a Powermac G5 dual 2.7 GHz desktop. I am connecting a Samsung 2233BW monitor. When I connect the monitor from its digital connection using the digital cable I have a problem bringing the monitor back from sleep mode. I get horizontal jagged li

  • Statistics in SQL Developer

    Hi, I have an anonymous block like: DECLARE             P_CURSOR              TYPES.REF_CURSOR;             P_SEARCH_TXT          CLOUD_USER.FIRST_NM%TYPE := 'as';             P_SEARCH_TXT1         CLOUD_USER.FIRST_NM%TYPE := 'as%';             P_SEA

  • Printing Text Entered into an Interactive Form

    I know this is a dumb question but no one in my office is going to believe it til it comes from the horse's mouth. When you complete an interactive form and the entered text is longer than the size of the text box (so that the   sign appears and can

  • When click on applications in finder it freezes computer

    whenever I click on the applications in my finder and start scrolling down it will freeze up. If i do it more then once sometimes it will take the toolbar off the screen and the only thing i can do is turn it off and back on. I tried listing the apps