0
votes

I need to be able to execute an update SQL script, but it isn't working

Here is a link to the site that I used for reference: https://groovyinsoapui.wordpress.com/tag/sql-eachrow-groovy-soapui/

Here is the format of the code that I ended up writing (due to the nature of the work I am doing, I am unable to provide the exact script that I wrote)

import groovy.sql.Sql

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
groovyUtils.registerJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver")

def connectString = "jdbc:microsoft:sqlserver://:;databaseName=?user=&password="

sql = Sql.newInstance(connectString)  // TEST YOUR CONNECT STRING IN A SQL BROWSER

sql.executeUpdate("UPDATE TABLE SET COLUMN_1 = 'VALUE_1' WHERE COLUMN_2 = 'VALUE_2'")

The response that I am getting is:

Script-result: 0

I also tried to use:

sql.execute("UPDATE TABLE SET COLUMN_1 = 'VALUE_1' WHERE COLUMN_2 = 'VALUE_2'")

Which returns the following response:

Script-result: false
1
Check if it is helpful - stackoverflow.com/questions/42294903/…Rao

1 Answers

0
votes

From what you say it seems that no row has COLUMN_2 = 'VALUE_2', so then number of updated rows is 0.

I would first check that statement on Management Studio just to make sure.