Anthony
Katalon Apprentice
05/16/2018
edited May 16

Get SQL query results as variables

Hello,

I am using the following code below to query a MS MSQL Server, and do not know how to deal with the results correctly...
CustomKeywords.'com.db.sql.connectDB'(server, port, dbname, username, password)

result = CustomKeywords.'com.db.sql.executeQuery'(query)

CustomKeywords.'com.db.sql.closeDatabaseConnection'()
The above is working (as in performing the query) using the example keywords from here, but how do I get the result of the query in a useable form.

If after running the above I do:
println result
Then all I get in the console is this:
SQLServerResultSet:1

How do I see/get at my results? I want to assign them to variables for comparison against others.

Thank you
Anthony

Upvote
Quote

Comments

  • Anthony
    Katalon Apprentice
    05/18/2018
    edited May 18
    Found a solution to get my results as variables.

    Using the built in data files functionality in Katalon Studio, I can create a data file connecting to my DB and then return the results as a variable with the below:

    //get data
    def data = findTestData('Data Files/DB Data')
    // Get specific data (column, row) as a variable
    String record = data.getValue(3, 4)
    //print my variable
    println record

    I can then do what ever I need with the variable :D

    Upvote
    Quote
Sign In or Register to comment.