Service Virtualization

  • 1.  How to run the Store Procedure via DevTest ?

    Posted Jun 14, 2017 12:33 AM

    I want to run the below storeProcedure in CA DevTest. When i am running in Oracle DB, i m getting the output.

     

    Output of the below code is 5 digit number : 12335

     

    Store Procedure :

     

    DECLARE
                  v_batch_id NUMBER;
              BEGIN
                  v_batch_id := UTIL_PRCS_PKG.GET_BATCH('TABLE_NAME');
                  dbms_output.put_line (v_batch_id);
              END;

     

    Is anyone came across the same issue. Pls provide the steps to run.

     

    -------------------------------------------

    I tried to run the Store_Procedure via "Java Script Step" using Java Code. I am getting the output as "Script Executed. Result is Class Main". But, I am expecting it should display "Batch_id".

     

    Store_Procedure name : UTIL_PRCS_PKG.GET_BATCH

    Table name : 'OMT_PROMOTION_STG'

     

    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.DriverManager;
    public class Main {
      static String url = "jdbc:oracle:thin:@ldap://p01imap.na.bestbuy.com:3060/d01frapt01,cn=OracleContext,dc=world";
      static String username = "FDM_H02APTK_BAT01";
      static String password = "h02aptkfr3sa23512";
      public static void main(String[] args) throws Exception {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection conn = DriverManager.getConnection(url, username, password);
        CallableStatement stmt = conn.prepareCall("{?= call UTIL_PRCS_PKG.GET_BATCH('OMT_PROMOTION_STG')}");
        stmt.registerOutParameter(1, java.sql.Types.VARCHAR);
     String batchID = callableStatement.getString(2);
        stmt.execute();
    System.out.println("BatchID : " + batchID);
        conn.close();
      }
    }
    Please help me in executing the above java code for SQL Store_Procedure.


  • 2.  Re: How to run the Store Procedure via DevTest ?

    Broadcom Employee
    Posted Jun 16, 2017 01:58 PM

    What version of DevTest are you running?



  • 3.  Re: How to run the Store Procedure via DevTest ?

    Posted Jun 18, 2017 11:41 PM

    DevTest 9.5.1



  • 4.  Re: How to run the Store Procedure via DevTest ?
    Best Answer

    Broadcom Employee
    Posted Jun 18, 2017 11:34 PM

    Assume, you have a below stored procedure like below.

     

    CREATE OR REPLACE PROCEDURE getBatchForTable
    IS
    DECLARE
    v_batch_id NUMBER;
    BEGIN
    v_batch_id := UTIL_PRCS_PKG.GET_BATCH('TABLE_NAME');
    dbms_output.put_line (v_batch_id);  // This will print output on dbms command screen and not displayed when you call it from workstation.
    END;

     

        If you want to execute this stored procedure, use SQL Database Exectution (JDBC) step in test case and add a statement as call <prodeduce_name> ex: call getBatchForTable

       If your produce has IN and OUT parameters, use ? and pass parameters in parameters section.

     

     

    Thanks

    Srikanth



  • 5.  Re: How to run the Store Procedure via DevTest ?

    Posted Jun 18, 2017 11:59 PM

    Thanks srikanth I do agree with your point regarding the call functionality with in or out parameters. But for the below query, there is no IN or OUR Parameter. 

     

    DECLARE
                  v_batch_id NUMBER;
              BEGIN
                  v_batch_id := UTIL_PRCS_PKG.GET_BATCH('TABLE_NAME');
                  dbms_output.put_line (v_batch_id);
              END;

     

    I do have query like the above scenario which you mentioned, for that i can give parameter name and value for each question mark. But, i m not able to see any result set or any positive response like successfully executed message.

     

    {call RETEK.GET_SKU_CAP_FEED_VIEW.GET_SKU_CAP_FEED
    (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}.

     

    Provide me with snap, if you ran the store-proc and got any success message on it.



  • 6.  Re: How to run the Store Procedure via DevTest ?

    Posted Jun 22, 2017 04:34 PM

    Hi,

         I think @Srikanth Gajawada  solution is most simplest way to execute Stored Procedure.I think  v_batch_id  is your Output parameter.

                                                                  Thanks,

    Regards,

    Vish
             



  • 7.  Re: How to run the Store Procedure via DevTest ?

    Posted Aug 31, 2017 01:09 AM

    Thank you Srikanth for your reply. Its working fine.

    We can get the out parameter by storing it in a property called "{{Result}}". With help of "Output Log Message", we can identify the out parameter.

     

     

     

     

     

     



  • 8.  Re: How to run the Store Procedure via DevTest ?

    Posted Aug 31, 2017 01:13 AM

    Run via ITR, we can able to see the output of store-procedure.



  • 9.  Re: How to run the Store Procedure via DevTest ?

    Posted Aug 31, 2017 01:17 AM

    When it is for IN Parameter, pass the value in Parameter section and post your query.

     

    This pic describes, all the 3 parameters are IN.