Forum Discussion

sparrowenclave's avatar
sparrowenclave
Occasional Contributor
5 years ago
Solved

How to add oracle row record in properties test step as key value pair in Soap UI tool

In Soap UI, I am able to connect oracle database using groovy Script.

then I fetched one record from the table.Now I wanted to know how we can set the record as key value in properties test step.

So I can assert the record in next script

  • sparrowenclave :

     

    I am hoping that you are doing same as below

    import groovy.sql.Sql;
    
    //Establish JDBC Connection to the DB
    def  con = Sql.newInstance(“jdbc:oracle:thin:@<url server database>:<port>:<sid>”, “username”, “password”, “oracle.jdbc.driver.OracleDriver”);
    
    def response = con.rows(“select * from employee”)
    
    //storing name in variable
    def name = response[0].name.toString()
    
    //setting name record in properties test step
    testRunner.testCase.getTestStepByName("Properties").setPropertyValue("emp_name",name)
    
    //closing DB Connection
    con.close()

     

    Hope it will help you in resolving your issue 🙂

  • HimanshuTayal's avatar
    HimanshuTayal
    5 years ago

     

    sparrowenclave :

     

    If the answer to the question is resolved in this question then it will advisable to ask new question in new thread, also you can ask in this too 🙂

     

     

6 Replies

  • sparrowenclave :

     

    I am hoping that you are doing same as below

    import groovy.sql.Sql;
    
    //Establish JDBC Connection to the DB
    def  con = Sql.newInstance(“jdbc:oracle:thin:@<url server database>:<port>:<sid>”, “username”, “password”, “oracle.jdbc.driver.OracleDriver”);
    
    def response = con.rows(“select * from employee”)
    
    //storing name in variable
    def name = response[0].name.toString()
    
    //setting name record in properties test step
    testRunner.testCase.getTestStepByName("Properties").setPropertyValue("emp_name",name)
    
    //closing DB Connection
    con.close()

     

    Hope it will help you in resolving your issue 🙂

    • sparrowenclave's avatar
      sparrowenclave
      Occasional Contributor
      Hi Himanshu,
      Agreed with the solutions.Thanks for the reply. I have another concern on the same issue but I am not sure whether I asked this in the question or ask a new question.
      Can you please suggest ?
      • HimanshuTayal's avatar
        HimanshuTayal
        Community Hero

         

        sparrowenclave :

         

        If the answer to the question is resolved in this question then it will advisable to ask new question in new thread, also you can ask in this too 🙂

         

         

  • nmrao's avatar
    nmrao
    Champion Level 3
    You can directly assert using script assertion without needing to have additional steps.
    • richie's avatar
      richie
      Community Hero
      nmrao,

      Oooh! Super efficient. I didnt think of that! 😉

      Rich