SOAP TO JDBC scenario: calling stored procedure which will return the value

Hi
I have Soap To Jdbc scenario in which I am going to call the Stored Procedure at target side which will be executed and it is going to return the result set .
Result contains following values.
return code as ( 0 Or 1) and also specific exception message if its return code as 1.
Could you suggest me the way by which I can handled this return code and send it back to the Sap PI system then the same thing is directed the to SMTP server for sending mail to consern person.
Regards
Kumar

The OUT parameters of stored procedure will be returned as response. Where exactly are you facing the proble? Here is a complete walkthourgh
/people/luis.melgar/blog/2008/05/13/synchronous-soap-to-jdbc--end-to-end-walkthrough
In your case, you don't want response at sender. Instead you want to mail it. For this you may use BPM to design your scenario with following steps
Receive (to receive data from sender)
Send Sync (to stored procedure and get response)
Send Async (to mail receiver)
Regards,
Prateek

Similar Messages

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • 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

  • I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".

    Hello,
    I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".
    Suppose , 
    Parameter value : person 1,person2,person3 
    table structure : 
    Project Name | officers 1 | officers 2
    here, officers 1 or officers 2 may contain names of multiple people.
    expected OUTPUT : distinct list(rows) of projects where person 1 or person 2 or person 3 is either officer1 or officer 2. 
    please explain or provide solution in detail 
    - Thanks

    Hi Visakh,
    Thanks for reply.
    But the solution you provided giving me right output only if officer 1 or officer 2 contains single value , not with comma seperated value.
    Your solution is working fine for following scenario : 
    Project 
    Officers 1
    Officers 2
    p1
    of11
    off21
    p2
    of12
    off22
    with parameter : of11,off22 : it will give expected output
    And its not working in case of :
    Project 
    Officers 1
    Officers 2
    p1
    of11,of12
    off21,off23
    p2
    of12,of13
    off22,off24
    with parameter : of11,off22 : it will not give any row in output
    I need patten matching not exact match :) 
    ok
    if thats the case use this modified logic
    CREATE PROC GetProjectDetails
    @PersonList varchar(5000)
    AS
    SELECT p.*
    FROM ProjectTable p
    INNER JOIN dbo.ParseValues(@PersonList,',')f
    ON ',' + p.[officers 1] + ',' LIKE '%,' + f.val + ',%'
    OR ',' + p.[officers 2] + ',' LIKE '%,' + f.val + ',%'
    GO
    Keep in mind that what you've done is a wrong design approach
    You should not be storing multiples values like this as comma separated list in a single column. Learn about normalization . This is in violation of 1st Normal Form
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Calling a Oracle Stored Procedure which will take a while to complete

    Hey.
    I'm calling a Oracle stored procedure which goes of and do a whole lot of things and therefore takes a fair while to complete.
    Currently I am doing this:
    String sql = "begin concorde.start_transfer(); end;";
    HibernateUtil.getSessionFactory().openStatelessSession().connection().prepareCall(sql).execute();
    ....Where HibernateUtil is just a mean to get to the SessionFactory. The connection I get is the same one as a JDBC, I think.
    I would want to regain control of the application as soon as the procedure is called and continue with the rest of the logic.
    How do I do that? Do I have to initiate it from a different thread?
    Thanks

    If it was me I wouldn't have a stored proc that took a while to complete. Instead I would submit a job to job queue. In terms of implementation I would call a proc that writes a record to a table. Then a process in the database polls that table and runs jobs it finds there. Then reports results somewhere.
    Sometime later you collect the results.
    But without that then the solution in java is obvious - create a thread.

  • JDBC performance calling stored procedures

    Hi,
    We have an java application which makes calls to PL/SQL stored procedures. We have one 'database server' component which handles all the database interaction, and other components which connect to it using CORBA.
    The problem is that with everything running, certain queries are taking from 17 to 30 seconds to come back, but when you run the same sql from SQLPlus, you get the results back in about 2 seconds every time.
    We're using a connection pool, but this doesn't seem to be the problem, as we put in diagnostics and it takes no time at all to get a free connection.
    The time is taken up doing a getCursor() to get the result set back. We register the cursor as an output parameter, and open it from within the stored procedure.
    Anyone any suggestions?
    Thanks,
    Neil.
    null

    Hi ,
    You can call stored procedure using JPA (eclipselink API).Below is the sample code
    ReadAllQuery readAllQuery = new ReadAllQuery(Employee.class);
    call = new StoredProcedureCall();
    call.setProcedureName("Read_All_Employees");
    readAllQuery.useNamedCursorOutputAsResultSet("RESULT_CURSOR");
    readAllQuery.setCall(call);
    List employees = (List) session.executeQuery(readAllQuery);
    Regards,
    Vinay

  • How to call a stored procedure which has out parameter value

    my code is
    public Connection createConnection() {
                   Connection conn = null;
                        try {
                             Class.forName(DRIVER);
                             conn = DriverManager.getConnection(URL,USER,PASS);
                        } catch (ClassNotFoundException cnfe) {
                             System.err.print("Class not found");
                        } catch (SQLException sqle) {
                             System.err.print("SQLException");
                   return conn;
         public static void main(String args[]){
              StroedProcedure stp = new StroedProcedure();
              Connection con = stp.createConnection();
              try {
                   CallableStatement stproc_stmt = con.prepareCall("{call Account_Summary(?,?,?,?,?,?,?,?)}");
                   stproc_stmt.setString(1, "123456");
                   stproc_stmt.setDate(2, null);
                   stproc_stmt.setString(3, null);
                   stproc_stmt.setString(4, null);
                   stproc_stmt.setString(5, null);
                   stproc_stmt.setString(6, null);
                   stproc_stmt.setDate(7, null);
                   stproc_stmt.setDate(8, null);
                   stproc_stmt.registerOutParameter(1,Types.CHAR);
                   stproc_stmt.registerOutParameter(2,Types.DATE);
                   stproc_stmt.registerOutParameter(3,Types.CHAR);
                   stproc_stmt.registerOutParameter(4,Types.CHAR);
                   stproc_stmt.registerOutParameter(5,Types.CHAR);
                   stproc_stmt.registerOutParameter(6,Types.CHAR);
                   stproc_stmt.registerOutParameter(7,Types.DATE);
                   stproc_stmt.registerOutParameter(8,Types.DATE);
                   stproc_stmt.execute();
                   System.out.println("test "+stproc_stmt.getString(1));
                   ResultSet rs = stproc_stmt.executeQuery();
                  while (rs.next()){
                       System.out.println("result "+rs.getString("ACCPK"));
              } catch (SQLException e) {
                        e.printStackTrace();
         }And the stored procedure is
    CREATE OR REPLACE
    procedure Account_Summary (accpk in out char, incdt out date, bcur out char, bmark out char, tarTE out char, numHold out char, stDt out date, AsDt out date)
    is
    begin
    select account_pk, inception_date, base_currency, benchmark  into accpk, incdt, bcur, bmark
    from account a
    where a.Account_pk=accpk;
    select target_te, number_holdings, start_date, as_date into tarTE, numHold, StDt, AsDt
    from acc_summary asum
    where asum.account_pk=accpk;
    end Account_Summary;but it gives a exception ORA-01460: unimplemented or unreasonable conversion requested
    ORA-06512: at "REPRO.ACCOUNT_SUMMARY", line 4
    ORA-06512: at line 1
    i want to execute a stored procedure which has in , inout or out parameter
    but it can not work

    ========================
    In some contects varchar2 variable limit is 32512 characters... October 16, 2003
    Reviewer: Piotr Jarmuz from Poznan, Poland
    Interesting to note is the fact that varchar2 variables as parameters to stored
    procedures (in in/out out) may be "only" 32512 bytes long.
    I've checked this in Java and Perl. 32512 is the last value that works, for any
    bigger it throws:
    Exception in thread "main" java.sql.SQLException: ORA-01460: unimplemented or
    unreasonable conversion requested
    But in PL/SQL as you said 32767
    Regards,
    Piotr
    =================================
    This i got it from ask tom, well it make sense.... try checking your input with small numbers and strings
    Have fun

  • Calling Stored procedure which uses Bulk Collect

    Hi All, I have Oracle stored procedure which uses Bulk Collect and returns table type parameter as output. Can anyone please help me how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. (I am successfully able to call using MS ODBC driver, but I want to use OraOLEDB driver.)

    861412 wrote:
    how Can I call this kind of stored procedures which returns table type output using VB and Oracle's Driver. This forum deals with the server-side languages SQL and PL/SQL.
    Your question deals with the client side and Visual Basic language.

  • Send SQL query or call stored procedure, which is best???

    hello experts!!
    i would like to ask what will be the best implementation on querying a database using Java, send a SQL query(insert into table values...) or call stored procedure(just pass parameters)?? and also in stored procedure does "autoCommit/rollback" applies/make sense??

    I searched google for this:
    Stored Procedures vs. SQL
    and found this useful link:
    http://www.karlkatzke.com/stored-procedures-vs-sql-calls/
    I thiink you should also read up on other articles based on such google searches
    to get other opinions. Also, read the links provided by that article.
    Personnally, I think stored procedures should be avoided unless there is a definite
    advantage as specified in the above article. Especially not used for CRUD operations.
    Also, no matter where you put the SQL, it should be documented. I've seen too many stored procedures that aren't documented.

  • Calling stored procedure multiple times in the JDBC receiver

    Hi,
    I am calling the stored procedure(SP) to update a DB table in the JDBC receiver.
    SP has 10 input parameters, and SP can receive one value for each parameter at a time.
    In my case, i will have multiple rows to insert using SP.i.e multiple values for each parameter.
    Its working correctly for a single value for each parameter, but when i have multiple values i want to call the SP multiples times.
    Is this possible and how?
    Thanks,
    Varghese.

    Varghese,
    I think you can have multiple statements in the JDBC Adapter's XML, as in http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm.
    Here the StatementName1 node can be inserted into your JDBC XML as often as you want.
    Kind regards,
    Koen

  • JDBC SQL Server Channel Calling Stored Procedure Won't Return Result Set

    Good afternoon, Experts
    We're calling a stored procedure in a sender communcation channel.  I can perform any SQL SELECT statement here, but for some reason when I execute the SP (EXECUTE StoredProcedureName) The Adapter Engine returns the following:
    Database-level error reported by JDBC driver while executing statement 'DECLARE @UpdateRecords bit SET @UpdateRecords = 0 EXECUTE ExportToSAP @UpdateRecords'. The JDBC driver returned the following error message: 'com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.'. For details, contact your database server vendor.
    Even stranger yet is is that this works just fine on our PI-DEV system.  I created an identical communication channel connecting to the same database with the same UID and PWD and it won't work in PI-QAS.
    Any help/ideas you could share would be greatly appreciated!!!
    Thanks,
    Chad

    Hi Chad.
    Normally, itu2019s a problem with your procedure. The Store Procedure is wrong and something is different between your DEV environment and QAS environment.
    Try to ask to DB team check it.
    Regards,
    Bruno

  • JDBC Control - Calling Stored Procedure

    Hi people,
    I have a big problem calling my procedure by jdbcControl, It might by easy to solve, but I don´t know what is wrong.
    My stored procedure return a Doube value, a key to be used in my system.
    Follow my Oracle procedure definition:
    --one cursor
    TYPE TCursor_Ret IS REF CURSOR;
    -- My procedure
    PROCEDURE PRSMS_RET_INVOKE_ID(pCURSOR OUT MY_PACKEGE.TCURSOR_RET) IS
    vNrChamadoServico sn_mensagem_portabilidade.nr_chamado_servico%TYPE; -- Number
    BEGIN
    -- THE IDENTIFICADOR HAS 15 digits
    vNrChamadoServico := FNSMS_BUSCA_VLR_PARAMETRO('0','IND_BASE_PORTAB') * power(10, 13);
    OPEN pCURSOR FOR
    SELECT (vNrChamadoServico + sq_nr_chamado_servico.NEXTVAL) AS invokeID
    FROM dual; -- retur '10000000000015'
    END PRSMS_RET_INVOKE_ID;
    In my JPD process I did something like this:
    public JdbcControl.SQLParameter[] parms = new JdbcControl.SQLParameter[1];
    --A cursor to be returned by oracle
    parms[0] = new JdbcControl.SQLParameter(new Double(0),Types.DOUBLE, JdbcControl.SQLParameter.OUT);
    myJdbcControl.getInvokeID(parms);
    In my jdbcControl I have:
    @JdbcControl.SQL(statement ="call MY_PACKAGE.PRSMS_RET_INVOKE_ID(?)")
    Double getInvokeID(JdbcControl.SQLParameter[] params)throws SQLException;
    And I got the following error:
    [BEA][Oracle JDBC Driver][Oracle]ORA-06553: PLS-306: wrong number or types of arguments in call to 'PRSMS_RET_INVOKE_ID'
    I am using the follow example:
    http://mail-archives.apache.org/mod_mbox/beehive-commits/200702.mbox/%[email protected]%3E
    I have Tried use as parameter LONG, NUMER, BIGDECIMAL and so one, but I haven't sucessfull. :(
    Could someone give me some hint?
    Edited by denimar at 06/10/2008 4:10 PM

    Hi guys,
    I Talked to my Oracle´s DBA and he give the the following advice:
    We changed the return TYPE.
    The old procedure returned TYPE TCursor_Ret IS REF CURSOR
    And now It return NUMBER
    FUNCTION FNSMS_RET_INVOKE_ID RETURN NUMBER IS
    vRESULT NUMBER;
    vCursor TCURSOR_RET;
    BEGIN
    PRSMS_RET_INVOKE_ID(vCursor);
    FETCH vCursor
    INTO vRESULT;
    RETURN(vRESULT);
    END FNSMS_RET_INVOKE_ID;
    Now I can catch the return value like this:
    select MY_PACKAGE.FNSMS_RET_INVOKE_ID from dual
    Bye bye!!

  • File to JDBC Scenario using stored procedure Question

    Does anyone have an aswer (or have you seen a Blog that covers it) to the problem of having to do a table refresh before doing inserts in a file 2 jdbc scenario?
    Essentially the details are as follows:
    I have an input file that has all the data for a table (it's a complete table dump) of lets say userdata (username, name, hiredate).
    I need to pass that to an oracle database via stored procedure(s).  But before I start issuing my insert (via insert stored procedure) I have to somehow issue a delete statement to delete all the contents of the table I'm about to update.  I'm on XI 3.0 and aren't sure what the best solution to this may be.
    Again if there is a blog that covers this then if you could point me in that direction it would be great.  Otherwise if anyone has any good ideas it would be appreciated.

    Hi,
    For structure refer this blog..
    /people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30
    Use two <Statement> tags as shown here and there you may have separate tablenames.
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm
    Thanks,
    Jogula Ramesh

  • Calling stored procedures with parameters with the Database Connectivi​ty Toolkit

    Hi all,
    I am new to the forum and am having difficulty finding a solution to a particular problem I am having regarding using the LabVIEW Database Connectivity Toolkit on a project I am currently working on at my job.  I have a database in which I have tables and stored procedures with parameters.  Some of these stored procedures have input, output, and return parameters.
    I have been trying to follow this example but to no avail:  http://digital.ni.com/public.nsf/allkb/07FD1307460​83E0686257300006326C4?OpenDocument
    One such stored procedure I am working on implementing is named "dbo.getAllowablePNs", which executes "SELECT * from DeviceType" (DeviceType is the table).  In this case, it does not require an input parameter, it has an output parameter that generates the table [cluster], and has a return parameter which returns an integer value (execution status code) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int, not null), PN (nvarchar(15), null), and NumMACAddresses (int, null).  I have gone over many examples and have talking to NI support to try to implement this and similar stored procedures in LabVIEW but have not been successful.  I am able to connect to the database with the Open Connection VI without error, but am running into some confusion following this step.  I am then trying to use the Create Parameterized Query VI to call the stored procedure and set the parameters.  I assume I would then use the Set Parameter Value VI for each parameter that is wired into the parameters input on the previous Parameterized Query VI?  I am also having some confusion during and following these steps as well.  I would greatly appreciate any advice or suggestions anyone might have in regards to this situation as I am not a SQL expert.  Also, I would be happy to provide any more information that would be helpful.
    Regards,
    Jon
    Solved!
    Go to Solution.

    Also, I don't know if this would be helpful but here is the actual stored procedure in SQL:
    CREATEPROCEDURE [dbo].[getLastSequenceNumber]
    @p1 nvarchar(10)='WO-00000'
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SETNOCOUNTON;
    -- Insert statements for procedure here
    selectmax(SequenceNumber)from Devices where WorkOrderNumber= @p1
    END
    GO

  • Writing a Stored Proc which will execute the Queries passed to it as args

    Hi,
    I need to write a Stored Proc which gets the Query to be executed as an Argument and return the results in an OUT Variable.
    The Stored Proc i wrote is
    CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
    l_returnValue out clob )
    is
    l_output utl_file.file_type;
    l_theCursor integer ;
    l_columnValue clob;
    l_status integer;
    l_results      clob;
    begin
    l_theCursor := dbms_sql.open_cursor;
    -- Parse the Query
    dbms_sql.parse( l_theCursor, ':x', dbms_sql.native );
    DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
    -- Define the coulmnValue Variables
    dbms_sql.define_column( l_theCursor, 1, l_columnValue);
    -- Execute the Query
    l_status := dbms_sql.execute(l_theCursor);
    -- Get the Results and prepare the return Value.
    loop
    exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
    dbms_sql.column_value( l_theCursor, 1, l_columnValue );
         DBMS_LOB.APPEND(l_returnValue, l_columnValue);
    end loop;
    -- Close the Cursor
    dbms_sql.close_cursor(l_theCursor);
    end SP_FETCH_RESULTS;
    As the Queries paased to it always return CLOB Types i declared the OUT Variable as CLOB
    And when i try to execute is using the below given PL/SQL Block
    DECLARE
    l_Query CLOB ;
    l_retVal CLOB;
    l_results CLOB;
    BEGIN
    l_Query:='SELECT extract(object_value,''/AC'').getStringVal() into l_results from CommonAssetCatalog';
    SP_FETCH_RESULTS(l_Query,l_retVal);
    dbms_output.put_line ('Results =');
    END;
    I am getting the Error.
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
    ORA-06512: at "SYS.DBMS_SQL", line 39
    ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
    ORA-06512: at line 7
    Could you guys pls give me some inputs on how to resolve this..
    Thanks a lot
    Sateesh

    Hi James,
    I tried with out the Bind Variable and got the Same Error..
    The Code which i tried earlier is
    CREATE OR REPLACE PROCEDURE SP_FETCH_RESULTS(l_query in varchar2,
    l_returnValue out clob )
    is
    l_output utl_file.file_type;
    l_theCursor integer ;
    l_columnValue clob;
    l_status integer;
    l_results      clob;
    begin
    l_theCursor := dbms_sql.open_cursor;
    -- Parse the Query
    dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
    --DBMS_SQL.BIND_VARIABLE(l_theCursor, ':x', l_query);
    -- Define the coulmnValue Variables
    dbms_sql.define_column( l_theCursor, 1, l_columnValue);
    -- Execute the Query
    l_status := dbms_sql.execute(l_theCursor);
    -- Get the Results and prepare the return Value.
    loop
    exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
    dbms_sql.column_value( l_theCursor, 1, l_columnValue );
         DBMS_LOB.APPEND(l_returnValue, l_columnValue);
    end loop;
    -- Close the Cursor
    dbms_sql.close_cursor(l_theCursor);
    end SP_FETCH_RESULTS;
    and the Procedure got Compiled Successfully and when i ran the PL/SQL Block which calls the Above Stored Proc i got the Error
    DECLARE
    ERROR at line 1:
    ORA-00905: missing keyword
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
    ORA-06512: at "SYS.DBMS_SQL", line 39
    ORA-06512: at "WEBLOGIC.SP_FETCH_RESULTS", line 13
    ORA-06512: at line 7
    Pls let me know how can i resolve this..
    Thanks
    Sateesh

Maybe you are looking for