Stored Procedure Call from XMII

Hi, I am facing the following problem.
My SQL Stored Procedure has one input parameter,and it returns three values.
I want to know the syntax for calling this stored procedure ie. syntax in  fixed query in XMII.
Thanks.

Hi Adam,
I assume that you are using MSSQL server stored procedure which outputs 3 values.
Say that you are inputting 1 integer @inval and returning 3 integer values @outval1, @outval2, @outval3 from Stored Procedure
Then perform the following in Query Template
DECLARE @val1 INT
DECLARE @val2 INT
DECLARE @val3 INT
EXEC StoredProcedureName
    @inval = 10,
    @outval1 = @val1 OUTPUT,
    @outval2 = @val2 OUTPUT,
    @outval3 = @val3 OUTPUT
SELECT @val1,@val2,@val3
Use FixedQuery mode
Regards,
Adarsh
Edited by: Adarsh Sidnoor on Aug 27, 2009 7:46 PM
Edited by: Adarsh Sidnoor on Aug 27, 2009 7:47 PM

Similar Messages

  • Stored Procedure call from JDBC sender for Oracle Database

    Hi,
    I have a requirement to call stored procedure using JDBC sender adapter for retriving data from an Oracle database.
    I need to execute first stored procedure call from Querry SQL statement and then trigger second stored procedure call for confirming the succesful retrival of those records from the update SQL statement.
    Querries:
    1. Can we trigger stored procedure from Update statement of JDBC sender.
    2. Can we call stored procedure from Querry statement, since I have read on other sdn threads that stored procedure calls on Oracle database are not allowed. If not possible to have "Execute stored procedure" would the function call (select * from table(function name)) work same as stored procedure.
    3. In a JDBC sender the Querry statement and Update statement are executed in same session call and same database connection. What happens if the querry statement was not succesful, would the update be still triggered.
    Please note PI does not have direct access to main table and hence the need to have separate stored procedure calls.
    The PI version is PI 7.11 sp4.
    Appreciate your inputs.
    Thanks.
    Siddhesh S.Tawate

    >1. Can we trigger stored procedure from Update statement of JDBC sender.
    I think not possible using update statement.
    > Can we call stored procedure from Querry statement, since I have read on other sdn threads that stored procedure calls on Oracle database are not allowed. If not possible to have "Execute stored procedure" would the function call (select * from table(function name)) work same as stored procedure.
    Yes using select query you can call stored procedure.
    >. In a JDBC sender the Querry statement and Update statement are executed in same session call and same database connection. What happens if the querry statement was not succesful, would the update be still triggered.
    No select and update handles in the same session using the same thread so if one transaction fails update should not proceed.

  • Execution Times of Stored Procedures Called from Other Stored Procedures

    If I execute sys.dm_exec_procedure_stats, it will produce execution times of my stored procedures executed recently.
    However, stored procedures called from other stored procedures do not show up.
    Is there code that can return the execution times of stored procedures even though they are called from other stored procedures.

    Look at the example. It is counting nested execution.
    CREATE PROC z1SP AS SELECT * FROM Production.Product;
    GO
    CREATE PROC z2SP AS SELECT * FROM Production.Product WHERE Color is not null; EXEC z1SP;
    GO
    SELECT object_name(2002822197), object_name(2034822311);
    --z1SP z2SP
    EXEC z1SP; EXEC z2SP;
    GO 10
    SELECT * from sys.dm_exec_procedure_stats
    database_id object_id type type_desc cached_time last_execution_time execution_count
    16 2002822197 P SQL_STORED_PROCEDURE 2014-12-16 13:02:45.170 2014-12-16 13:02:46.717 20
    16 2034822311 P SQL_STORED_PROCEDURE 2014-12-16 13:02:45.460 2014-12-16 13:02:46.687 10
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Passing UDT TABLE of VARCHAR as an Input parameter in Stored procedure call from java

    I have following Type defined at the schema: ident_arr IS TABLE OF VARCHAR2(100) which is type of one of the input parameters. I am able to create oracle.sql.ARRAY object to map it with this UDT before calling my stored procedure from java. When I execute my stored procedure, I get the following error:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'P_PV_WCC_INSERT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I have already checked all other parameter types.

    Hello,
    Thank you, guys, for advice. I should have explained calling context before, but what I basically need to do is to see if procedure(arg1, list(record(arg2, arg3))) returns true.
    I see array binding wouldn't fit there nicely. Internal procedure calls would be proc(next(arg1), next(arg2), next(arg3)) - if all these return true, external call should also return true. I would need to make a list of repeating values of arg1 and separate list(record(arg2, arg3)) into separate lists. I would also need to record whether the internal call returns true to deduce whether external call returns true.
    As I see no better way yet, I'll make Oracle procedure proc(arg1, arg2, arg3) and implement a loop in .NET side. If I optimize for performance, I'll probably pack the array of records into string and pass it for Oracle side to parse.
    Regards,
    Aurimas Pranskevicius

  • Stored Procedure calling from EJB

    Can i call a stored procedure from a EJB. First time attempt.
    IF some details available will help me a lot

    You may just use JDBC to call a stored procedure from a BMP
    bean. Below is a section from the "Oracle JDBC Developer's Guide
    and Reference":
    As an example of using Oracle syntax, here is a PL/SQL code
    snippet that creates a stored function. The PL/SQL function gets
    a character sequence and concatenates a suffix to it:
    create or replace function foo (val1 char)
    return char as
    begin
    return val1 || 'suffix';
    end;
    Your invocation call in your JDBC program should look like:
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:oci8:@<hoststring>", "scott", "tiger");
    CallableStatement cs = conn.prepareCall ("begin ? := foo(?);
    end;");
    cs.registerOutParameter(1,Types.CHAR);
    cs.setString(2, "aa");
    cs.executeUpdate();
    String result = cs.getString(1);

  • Stored Procedure Call from Bean Error - PLS-00201

              Hello all,
              I am using the java stored procedure code in the examples dir of weblogic51/examples/jdbc/...
              with one exception. I created the stored procedure as another user with more
              permissions than
              the user that the jdbc connection will be established with. I created a public
              synonym so the stored
              procedure doesn't have to be refered to as "username.proc_squareInt". I keep
              getting the following
              errors. The web user has execute permissions and I tried calling it both with
              the owner.proc_name
              and proc_name (which I know won't work since it won't be able to find it).
              Any help would be greatly appreciated.
              Sincerely,
              Michael Prinsen
              Tue Jul 17 13:47:41 MDT 2001:<E> <WebAppServletContext-et> Root cause of ServletException
              java.sql.SQLException: ORA-06550: line 1, column 7:
              PLS-00201: identifier 'WTHDBM.PROC_SQUAREINT' must be declared
              ORA-06550: line 1, column 7:
              PL/SQL: Statement ignored
                   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
                   at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
                   at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542)
                   at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1330)
                   at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:757)
                   at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1313)
                   at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1232)
                   at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement.java:1353)
                   at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:1760)
                   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1807)
                   at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:332)
                   at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:376)
                   at weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java:35)
                   at csu.et.testBean.getWeatherData1(testBean.java:46)
                   at jsp_servlet._test._tester._jspService(_tester.java:107)
                   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:138)
                   at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
                   at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
                   at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
                   at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
                   at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
              // START CODE
              package csu.et;
              import java.io.*;
              import java.sql.*;
              import java.util.*;
              import java.text.*;
              import java.beans.*;
              import java.math.*;
              import java.util.Date;
              import java.util.Locale;
              import csu.util.*;
              public class testBean {
              public String getWeatherData1() throws SQLException {
              Connection conn = null;
              conn = CSUConnection.getConnection("etSelectConnectionPool");
              // Create a stored proc - (CREATED ALREADY)
              // Statement stmt1 = conn.createStatement();
              // stmt1.execute("CREATE OR REPLACE PROCEDURE proc_squareInt " +
              // "(field1 IN OUT INTEGER, " +
              // " field2 OUT INTEGER) IS " +
              // "BEGIN field2 := field1 * field1; " +
              // "field1 := field1 * field1; END proc_squareInt;");
              // stmt1.close();
              String sql = "{call proc_squareInt(?, ?)}";
              CallableStatement cstmt1 = conn.prepareCall(sql);
              cstmt1.registerOutParameter(2, java.sql.Types.INTEGER);
              for (int i = 0; i < 5; i++) {
              cstmt1.setInt(1, i);
              cstmt1.execute();
              System.out.println(i + " " + cstmt1.getInt(1) + " " + cstmt1.getInt(2));
              cstmt1.close();
              conn.close();
              return("hard-coded stuff");
              //END CODE
              

    this is probably an oracle related issue, and has very little to do with
              Weblogic transactions.
              your easiest way to debug this is to open a SQL/Plus window, log in as user
              WTHDBM and try to run the command
              "execute proc_squareInt(5,5);"
              "execute owner.proc_squareInt(5,5);"
              if this doesn't work, consult Oracle technet on how to setup synonyms and
              permissions
              Filip
              ~
              Namaste - I bow to the divine in you
              ~
              Filip Hanik
              Software Architect
              [email protected]
              www.filip.net
              "Michael Prinsen" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hello all,
              >
              > I am using the java stored procedure code in the examples dir of
              weblogic51/examples/jdbc/...
              > with one exception. I created the stored procedure as another user with
              more
              > permissions than
              > the user that the jdbc connection will be established with. I created a
              public
              > synonym so the stored
              > procedure doesn't have to be refered to as "username.proc_squareInt". I
              keep
              > getting the following
              > errors. The web user has execute permissions and I tried calling it both
              with
              > the owner.proc_name
              > and proc_name (which I know won't work since it won't be able to find it).
              >
              > Any help would be greatly appreciated.
              >
              > Sincerely,
              >
              > Michael Prinsen
              >
              > Tue Jul 17 13:47:41 MDT 2001:<E> <WebAppServletContext-et> Root cause of
              ServletException
              > java.sql.SQLException: ORA-06550: line 1, column 7:
              > PLS-00201: identifier 'WTHDBM.PROC_SQUAREINT' must be declared
              > ORA-06550: line 1, column 7:
              > PL/SQL: Statement ignored
              >
              > at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
              > at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
              > at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542)
              > at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1330)
              > at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:757)
              > at
              oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1313
              > at
              oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1232)
              > at
              oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement.java:1
              353)
              > at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:1760)
              > at
              oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
              :1807)
              > at
              oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedState
              ment.java:332)
              > at
              oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.j
              ava:376)
              > at weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java:35)
              > at csu.et.testBean.getWeatherData1(testBean.java:46)
              > at jsp_servlet._test._tester._jspService(_tester.java:107)
              > at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              > at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :120)
              > at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :138)
              > at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:915)
              > at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java:879)
              > at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java:269)
              > at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
              > at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
              >
              >
              >
              > // START CODE
              >
              > package csu.et;
              >
              > import java.io.*;
              > import java.sql.*;
              > import java.util.*;
              > import java.text.*;
              > import java.beans.*;
              > import java.math.*;
              > import java.util.Date;
              > import java.util.Locale;
              > import csu.util.*;
              >
              > public class testBean {
              >
              > public String getWeatherData1() throws SQLException
              >
              > Connection conn = null;
              > conn = CSUConnection.getConnection("etSelectConnectionPool");
              >
              > // Create a stored proc - (CREATED ALREADY)
              > // Statement stmt1 = conn.createStatement();
              > // stmt1.execute("CREATE OR REPLACE PROCEDURE proc_squareInt " +
              > // "(field1 IN OUT INTEGER, " +
              > // " field2 OUT INTEGER) IS " +
              > // "BEGIN field2 := field1 * field1; " +
              > // "field1 := field1 * field1; END proc_squareInt;");
              > // stmt1.close();
              >
              > String sql = "{call proc_squareInt(?, ?)}";
              > CallableStatement cstmt1 = conn.prepareCall(sql);
              >
              > cstmt1.registerOutParameter(2, java.sql.Types.INTEGER);
              > for (int i = 0; i < 5; i++) {
              > cstmt1.setInt(1, i);
              > cstmt1.execute();
              > System.out.println(i + " " + cstmt1.getInt(1) + " " +
              cstmt1.getInt(2));
              > }
              >
              > cstmt1.close();
              > conn.close();
              > return("hard-coded stuff");
              > }
              >
              > }
              >
              > file://END CODE
              

  • Who know how to handle pl/sql table return from stored procedure calling from jsp

    I have some stored procedure which return pl/sql table (index by table), It is look like an array. how jdbc handle this?
    CallableStatement cs = con.prepareCall("EXECUTE bill.getcountry(?,?)");
    cs.setInt(1, cid);
    cs.registerOutParameter(2, java.sql.Types.VARCHAR);// ARRAY?
    ResultSet rs = cs.executeQuery();
    Array array = (Array) rs.getObject (1);
    ResultSet array_rset = array.getResultSet ();

    Not that familiar with the OCI (Oracle Call Interface), but I think this call will be problematic - the OCI deals with SQL data types and not with PL/SQL structures.
    The OCI has since Oracle 8i sported an object call interface (see OCI Runtime Environment for Objects for details).
    This allows you to use the CREATE TYPE command to create advance user data types - and these are supported by the SQL engine, PL/SQL engine and external languages via the OCI.
    So you need to have a look at the Perl-DBI documentation to see how it supports Oracle object types and consider using these. As for internal PL/SQL data structures. These are not supported by the SQL engine and I would expect limited or no support in the OCI for these. Anyway, using SQL data types makes a lot more sense ito flexibility and transparency across languages and environments.

  • Too many arguments for stored procedure call

    I have a stored procedure with 34 arguments, including the return value. I am trying to call it from java using JDBC thin drivers (jdk11, oracle815), but I get the "wrong number or types of arguments" error message. JDBC-OCI fails also. I saw a reference in this discussion group to there being a limit of 32 arguments for stored procedure calls from jdbc (posted 6/29/99). Is there such a limit? If so, is there a fix or workaround? If there is not a limit, how can I determine which argument is causing the problem?
    Many thanks.
    Mike
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00306: wrong number or types of arguments in call to 'PUT_CHECK'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.jav
    a)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement
    .java)
    at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepar
    edStatement.java)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
    ement.java)
    at metris.quickcheck.database.DS1.main(DS1.java:79)
    null

    I must confess I still don't understand your problem. By rows ...
    I have an sql that recodes a column and has 1450 rows. This doesn't work
    although when I use the same with less rows 40-60 it works.... do you mean rows in the table or elements in the CASE() statement ?
    From the 9i SQL Reference:
    " The maximum number of arguments in a CASE expression is 255, and each WHEN ... THEN pair counts as two arguments. To avoid exceeding the limit of 128 choices, you can nest CASE expressions. That is return_expr can itself be a CASE expression."
    According to the 10g docs the limit is the same there.
    Cheers, APC

  • Response from one stored proc. to another stored procedure call in JDBC

    Hi,
    I have to call 2 stored procedures, where the response from first stored procedure ( an id) is mapped as a parameter to the second stored procedure call.
    My question is that can this be achieved without using BPM?
    Can we somehow map the response from the stored procedure 1 to stored procedure 2 parameter w/o using BPM?
    I have to insert multiple rows using the stored procedure.
    Should I use STATEMENT unbounded times ( which means stored procedure is called multiple times) or should I use the parameter as unbounded ( like an array, maybe define the parameter as an array in the stored procedure)?
    From the performance standpoint, which approach is better?
    Please suggest.

    Hi Ardent !
    I think you could use 2 mapping programs (message mapping objects) in your interface mapping. The first one, executes and returns the ID to a message type defined by you for internal use only between both stored procedure executions. The second ones uses that message type as source message and the XML required by the JDBC for the second stored procedure execution as target message type. This can be done without BPM.
    Regards,
    Matias.

  • Capture error messages from stored procedure calls

    Hi there,
    How do I capture a stored procedure calls error messages provided the stored procedures does not have output parameters? This questions applies to Oracle 7.3.4 stored procedures calls.
    TQ
    Neo

    There are two parts.
    The stored proc must 'throw' an exception.
    And java must catch it.
    You probably already have the java part. That is the catch(SQLException).
    As for the stored proc you can use the following search string in the jdbc forum
    raise oracle
    You need to use 'raise' in the stored proc but I am not sure of the exact form, but one of the threads using the above search string is likely to have it.

  • Remote Stored Procedure Call Dispatcher WEB WERVICE

    Hello all,
    Environment: Windows OS, Oracle 10g, mod_plsql
    I am looking for solutions to the following problem:
    A way to dispatch calls to stored procedures from client to server with a minimal impact on performance.
    We are looking at two possible solutions:
    1) Making a call to a Remote Stored Procedure Call Dispatcher (RSPCDispatcher) stored procedure through mod_plsql.
    2) Making a call to a Remote Stored Procedure Call Dispatcher (RSPCDispatcher) stored procedure through a web service.
    Solution 1) is not the preferred one as you may already know that mod_plsql will not be supported starting 12g.
    Solution 2) is the one we prefer as we believe that web services will be ever more supported in the future. When we move to 11g we may turn this web service into a native one (avoiding overhead in the OC4J for hosting the web service etc.).
    We are looking for code examples and information pointers of how we could implement this dispatcher as a stored procedure in a DB package. We know that the implementation should be similar to the one done for mod_plsql in the OWA schema but the code there is obfuscated, so we could not borrow ideas from there.
    We are not sure how to deal with the generalization of the above stated problem. We need to be able to pass to this dispatcher the stored procedure package and name we are invoking, ordered list of parameters (or parameters map), and the transport strategy (XML, JSON, etc.).
    Basically, we are notsure how to deal with the USING clause of the EXECUTE IMMEDIATE statement. We can dynamically generate the SQL statement corresponding to the stored procedure we want to call, but we are not sure how to bind the parameters we are passing?
    Also, we know that EXECUTE IMMEDIATE may be slow sometimes. So if could avoid it, this could further improve performance.
    Perhaps the run-time generalized stored procedure execution may not be what we are looking for?! Perhaps we should include several design-time steps?! What about a script that given a package name (or just a single stored procedure) would generate a wrapper package which stored procudures' names would correspond to their respective counterparts in the given package which would take two parameters - the list of parameters in some sort of format, and the transport (content delivery strategy) and would return the result in the given content delivery strategy?! This script may also define the XSD of the XML message a stored procedure is called with (the parameter map) as well as the XSD of the XML result the stored procedure returns. Also the script could generate client code with the given language strategy (Java, .NET, etc.) for calling the RSPCDispatcher web service.
    We request the following from the Oracle community folks:
    a) Please, give us any relevant information that could be helpful to resolve this problem.
    b) Any resource of how to inspect stored procedures in a package, its parameters, parameter types and direction (IN, OUT, or INOUT), etc.
    Thank you very much in advance.
    Regards,
    Georgi

    Hello all,
    Environment: Windows OS, Oracle 10g, mod_plsql
    I am looking for solutions to the following problem:
    A way to dispatch calls to stored procedures from client to server with a minimal impact on performance.
    We are looking at two possible solutions:
    1) Making a call to a Remote Stored Procedure Call Dispatcher (RSPCDispatcher) stored procedure through mod_plsql.
    2) Making a call to a Remote Stored Procedure Call Dispatcher (RSPCDispatcher) stored procedure through a web service.
    Solution 1) is not the preferred one as you may already know that mod_plsql will not be supported starting 12g.
    Solution 2) is the one we prefer as we believe that web services will be ever more supported in the future. When we move to 11g we may turn this web service into a native one (avoiding overhead in the OC4J for hosting the web service etc.).
    We are looking for code examples and information pointers of how we could implement this dispatcher as a stored procedure in a DB package. We know that the implementation should be similar to the one done for mod_plsql in the OWA schema but the code there is obfuscated, so we could not borrow ideas from there.
    We are not sure how to deal with the generalization of the above stated problem. We need to be able to pass to this dispatcher the stored procedure package and name we are invoking, ordered list of parameters (or parameters map), and the transport strategy (XML, JSON, etc.).
    Basically, we are notsure how to deal with the USING clause of the EXECUTE IMMEDIATE statement. We can dynamically generate the SQL statement corresponding to the stored procedure we want to call, but we are not sure how to bind the parameters we are passing?
    Also, we know that EXECUTE IMMEDIATE may be slow sometimes. So if could avoid it, this could further improve performance.
    Perhaps the run-time generalized stored procedure execution may not be what we are looking for?! Perhaps we should include several design-time steps?! What about a script that given a package name (or just a single stored procedure) would generate a wrapper package which stored procudures' names would correspond to their respective counterparts in the given package which would take two parameters - the list of parameters in some sort of format, and the transport (content delivery strategy) and would return the result in the given content delivery strategy?! This script may also define the XSD of the XML message a stored procedure is called with (the parameter map) as well as the XSD of the XML result the stored procedure returns. Also the script could generate client code with the given language strategy (Java, .NET, etc.) for calling the RSPCDispatcher web service.
    We request the following from the Oracle community folks:
    a) Please, give us any relevant information that could be helpful to resolve this problem.
    b) Any resource of how to inspect stored procedures in a package, its parameters, parameter types and direction (IN, OUT, or INOUT), etc.
    Thank you very much in advance.
    Regards,
    Georgi

  • DML visibility in stored procedures called via JDBC

    Hello,
    I have two stored procedures, A and B. Proc A inserts Q into table X. Proc B selects Q from table X to insert it into table Y. Neither procedure does a COMMIT.
    My Java class executes Proc A and then Proc B within a transaction (autocommit is false). But Proc B fails to select Q from table X with the No Data Found error, apparently unable to see the recently inserted Q.
    If these two procedures are called from a SQL*Plus block, everything succeeds.
    Does anyone have a clue about what I am missing? All my DML should be visible to my session.
    Thank you in advance for any suggestions.
    - CJ

    Thank you, Joe, for your reply!
    To the best of my knowledge, all of my stored procedure calls are being made from the same connection so I can rollback everything if necessary. I have not explicitly closed the connection between calls. The debugger indicates my connection session id never changes across calls.
    Do you know of any JDBC trace tools that might help me verify my connections? I've enabled logging with oracle.jdbc.driver.OracleLog.setTrace(true) but it doesn't really give me specific connection information - at least not that I can tell. :)
    Thanks!
    Cori

  • Stored procedure call returns null result set when using temp table in sp!

    Here's a really odd problem...
    SQL Server stored procedure called sp_Test takes 1 input INT. Here is the code I call it with
    cStmt = connection.prepareCall("{call sp_Test(?)}");
    cStmt.setInt(1, 44);
    cStmt.execute();
    rs = cStmt.getResultSet();When the body of the stored proc is
    CREATE PROCEDURE sp_Test(@i_NodeID INT)
    AS
    BEGIN
      SELECT node_id FROM tbl_NavTree
    END
    GOthe query works and I get all node_id back in rs
    BUT when the body of the stored proc is
    CREATE PROCEDURE sp_Test(@i_NodeID INT)
    AS
    BEGIN
      CREATE TABLE #Descendants(
        descendant_id INT
      SELECT node_id FROM tbl_NavTree
      DROP TABLE #Descendants
    END
    GOThe rs comes back as NULL. Really really weird if you ask me. I also tried removing the DROP TABLE line just in case the SELECT had to be the last statement but still NULL.
    Final note is that BOTH the above stored proc bodies work when executed within SQL Server query analyser.
    Must be JDBC .. what can it be!??

    DROP TABLE #DescendantsMS SQL Server - right?
    Then don't drop the table.
    From the MS docs for "create table"
    Local temporary tables are visible only in the current session;
    A local temporary table created in a stored procedure is dropped automatically when the stored procedure completes. The table can be referenced by any nested stored procedures executed by the stored procedure that created the table. The table cannot be referenced by the process which called the stored procedure that created the table.

  • JDBC callableStatement stored procedure call cancellation?

    up vote0down votefavorite
    I have a very complex oracle stored procedure that searches and retrieves some data. The procedure returns an output parameter - an oracle cursor. I execute the procedure by JDBC:
    CallableStatement stmt = conn.prepareCall("{call myprocedure(?,?,?,?}");
    The problem is, the queries can sometimes take quite long (few minutes) and i would like user to be able to cancel the query anytime by clicking button. I have reference to stmt object, but unfortunatelly calling stmt.cancel() (from other thread) has NO EFFECT.
    On the other hand when i change the CallableStatement sql to some query like:
    CallableStatement stmt = conn.prepareCall("select * from all_objects");
    i get "java.sql.SQLTimeoutException: ORA-01013: user requested cancel of current operation" after calling stmt.cancel() - so thats the right reaction.
    Does that mean than i cannot cancel stored procedure call via jdbc, but only simple select statements? Does anyone else had and resolved similar problem?
    I guess i could cancel the query by oracle kill session, but i use connection pooling (jboss) and i have plenty of sessions for the same user existing.
    Database Product Version is Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production JDBC Driver Version is 11.2.0.4.0
    any help will be appreciated.

    This property didnt help, still no reaction after statement.cancel().
    I could not cancel the statment from the db size , so i decided to spawn new java thread and run the statement in that thread, and when user clicks cancel button i just cancel the thread, some snipper of code below:
                   AtomicBoolean userCanceled - this must be AtomicBoolean or  volatile variable, so other threads would see the change of variable after clicking button
                   try{
                    MyCallableQuery callable = new MyCallableQuery(rs,stmt,this,rsh,outParameter);
                    FutureTask<T> queryTask = new FutureTask<T>(callable);
                    ExecutorService executor = Executors.newFixedThreadPool(1);
                    executor.execute(queryTask);                 
                    while  (!queryTask.isDone()){         //stil processing statement            
                     Thread.sleep(100);
                          if (userCanceled)){               //user decided to cancel
                           futureTask1.cancel(true);
                           executor.shutdown();
                           throw new SQLException("User decided to cancel procedure call");
                     result = futureTask1.get(); 
                     //here the code after the resultset has been processed without cancelation
                   catch (SQLException e}{
                   //here the code when user decided to cancel  like clearing the datatable
    and my callable class is like:
    public class MyCallable<T> extends ProcRunner implements Callable<T> {
        private ResultSet rs;
        private CallableStatement stmt;
        private ProcRunner procRunner;
        private ResultSetHandler<T> rsh;
        private Integer outParameter;
        public MyCallable(ResultSet rs,CallableStatement stmt,ProcRunner procRunner,ResultSetHandler<T> rsh,Integer outParameter){
            this.rs = rs;
            this.stmt = stmt;
            this.procRunner = procRunner;
            this.rsh = rsh;
            this.outParameter = outParameter;
        @Override
        public T call() throws Exception {
           T result = null;     
          stmt.executeUpdate();
           rs = (ResultSet) stmt.getObject(outParameter);
           rs = this.wrap(rs);
           result = rsh.handle(rs);  
        return result;

  • WCF OData Service stored procedure call generates "Operation could destabilize the runtime" error with $select option

    I've been trying to call a stored procedure through Entity Framework and WCF Data Services (OData). It returns an entity not a complex type. Following walkthroughs found all over the web, I came up with this code inside my service:
    [WebGet]
    public IQueryable<Entity> GetEntitiesByParameterId(int parameterId)
    return CurrentDataSource.GetEntitiesByParameterId(parameterId).AsQueryable();
    Calling the proc this way: ~WcfService.svc/GetEntitiesByParameterId?parameterId=1 executes
    the stored procedure and returns entities that should be returned. No problem there.
    Everything works well until I try to use $select OData option ie. ~WcfService.svc/GetEntitiesByParameterId?parameterId=1&$select=name.
    Upon debugging, the method above runs without any error but it returns an Operation could destabilize the runtime error upon reaching the
    client. After so much research, apparently it is a very general error pointing to a lot of different causes. I haven't found one that really matches my particular problem. Closest are 
    http://stackoverflow.com/questions/378895/operation-could-destabilize-the-runtime
    https://social.msdn.microsoft.com/Forums/en-US/d2fb4767-dc09-4879-a62a-5b2ce96c4465/for-some-columns-entity-properties-executestorequery-failed-with-error-operation-could?forum=adodotnetdataservices 
    but none of the solutions worked on my end.
    Also, from the second article above:
    This is a known limitation of WCF DS. ...
    Second is that some of the queries won't work correctly because LINQ to EF needs little different LINQ expressions than LINQ to Objects in some cases. Which is the problem you're seeing.
    It has been posted on 2012. If it its true, are there still no updates on this? And is there any other workaround to get the $select working on the stored proc call?
    What works:
    ~WcfService.svc/GetEntitiesByParameterId?parameterId=1
    ~WcfService.svc/GetEntitiesByParameterId?parameterId=1&$top=1
    ~WcfService.svc/GetEntitiesByParameterId?parameterId=1&$skip-5
    ~WcfService.svc/GetEntitiesByParameterId?parameterId=1&$filter={filter query}
    ~WcfService.svc/GetEntitiesByParameterId?parameterId=1&$expand=SomeNavigationProperty
    What doesn't work:
    ~WcfService.svc/GetEntitiesByParameterId?parameterId=1&$select=name
    Tech details:
    EntityFramework 5, WCF Data Service 5.0, OData V3
    *I've also tried upgrading to EF6 and WCF 5.6.2 and it still didn't work.
    Any help would be appreciated. Thanks!

    Someone from SO replied to my question there and said that $select is still not supported though I couldn't find any definitive documentation about it.
    From what I gather and observed, $select breaks the stored procedure call because it tries to alter the data shape already gotten from the database and attempts to return a dynamic entity instead. Something about the stored proc returning an ObjectResult might
    be messing it up. As I have said, these are merely my observations.
    Workaround: I found a simple and elegant workaround for it though. Since my stored procedures are only getting data from the database and does
    not alter data in any way (INSERT, UPDATE, DELETE), I tried using table-valued functions that returns a table equivalent to the entity on my EF. I've found that calling this function on the Service Operation method returns an IQueryable<Entity> which
    is basically what is needed. $select also works now and so does other OData query options.
    Steps:
    Create a function on the database
    Update EDMX -> Add function
    Add new Function Import with Entity return type
    Create service operation in WCF Data Service that calls CurrentDataSource.<FunctionName>()
    Test in fiddler.
    CODES
    Database Function:
    CREATE FUNCTION GetEntities(@parameter)
    RETURN @entites TABLE(
    [Id] [int],
    [Name] [nvarchar](100),
    AS
    BEGIN
    INSERT INTO @entities
    SELECT [Id], [Name], ... FROM [EntityTable]
    RETURN
    END
    WCF:
    [WebGet]
    public IQueryable<Entity> GetEntity(int parameter)
    return CurrentDataSource.GetEntity(parameter);
    It doesn't really solve the stored procedure problem but I'm marking this as answer until someone can provide a better one as it does solve what I'm trying to do.
    Hope this helps others too. :)

Maybe you are looking for