Forum Discussion

alexis733's avatar
alexis733
Occasional Contributor
8 years ago

Re: Comparing JDBC results

Hello there,

 

I'm having the same problem. In my case I need to create a JDBC Request to "count" the elements on a certain table of a DB, then I performed some deletions from the DB and later assert if the deletions were performed in the DB. How to store the "count" of elements on the first JDBC Request so then I can compare it with the second "count" JDBC Request (this is the way, in my case, I use to compare if records removed form the first JDBC Request). 

 

Any help please?

 

Thanks in advance

  • PaulMS's avatar
    PaulMS
    8 years ago

    You can transfer the result of a JDBC request using a property transfer test step or a script assertion (below)

     

    import com.eviware.soapui.support.XmlHolder
    holder = new XmlHolder( context.responseAsXml )
    context.testCase.setPropertyValue( "Quantity", holder.getNodeValue("//QUANTITY") )

     Note //QUANTITY is in uppercase assuming the default setting to convert names of fields in request results to uppercase

  • nmrao's avatar
    nmrao
    Champion Level 3
    Provide more details such as your request etc so that some will be able to help.
    • alexis733's avatar
      alexis733
      Occasional Contributor

      Hello,

       

      This is the SQL statement I want to run before the deletion request.

       

      Select COUNT(*) as quantity
      from dbo.EXP
      where PID = Convert(numeric,:id)     -> id is taken from a Property previously declared.

       

      After the deletion request, I would like to run the same sql statement and in order to compare the quantity and thus assert if the deletion were performed successfully.

       

      Thanks,

       

       

      • PaulMS's avatar
        PaulMS
        Super Contributor

        You can transfer the result of a JDBC request using a property transfer test step or a script assertion (below)

         

        import com.eviware.soapui.support.XmlHolder
        holder = new XmlHolder( context.responseAsXml )
        context.testCase.setPropertyValue( "Quantity", holder.getNodeValue("//QUANTITY") )

         Note //QUANTITY is in uppercase assuming the default setting to convert names of fields in request results to uppercase