Inserting 10000 rows of data in database
Hi all, Goal: Use groovy to insert several rows in the database. Here I have to insert 10000 zipcodes with validity true or false in oracle database. Achieved: Know to insert one row Following is the code import groovy.sql.Sql import java.sql.SQLException import com.eviware.soapui.support.GroovyUtils.* try { def dbURL = context.expand('${#Project#ORACLE12c}') def dbUser = context.expand('${#Project#SchemaUser}') def dbPass = context.expand('${#Project#Pass}') def dbDriver = context.expand('${#Project#ORACLEDriver}') def dbconf = context.expand('${#Project#SchemaConf}') com.eviware.soapui.support.GroovyUtils.registerJdbcDriver(dbDriver) def sql = Sql.newInstance(dbURL, dbUser, dbPass, dbDriver) sql.execute("DELETE FROM "+dbconf+".ZipCodes WHERE VALID='true'") sql.execute("INSERT INTO "+dbconf+".ZipCodes (ZIPCODE, VALID) VALUES ('71232', 'true')"); } catch (SQLException e){ def tmp = e.getSQLState () log.error (tmp, e) } How to insert several rows using groovy teststep or even JDBC teststep? Pls ignore the syntax error, if any.Solved2.7KViews0likes3CommentsGroovy script for database manipulation using project property
I want to execute simple delete query with the schema nametaken from project properties, but I am not sure how to pass the value to it, current way doesn't work for me. import groovy.sql.Sql import com.eviware.soapui.support.GroovyUtils.* def dbURL = context.expand('${#Project#MSSQLUrl}') def dbUser = context.expand('${#Project#MSSQLUser}') def dbPass = context.expand('${#Project#MSSQLPassword}') def dbDriver = context.expand('${#Project#MSSQLDriver}') def dbschema1 = context.expand('${#Project#Schema1}') def dbschema2 = context.expand('${#Project#Schema2}') com.eviware.soapui.support.GroovyUtils.registerJdbcDriver(dbDriver) log.info (dbschema1) //logsEMP_SCHEMA def sql = Sql.newInstance(dbURL, dbUser, dbPass, dbDriver) sql.execute("DELETE FROM ['$dbschema1'].[dbo].[JOB] WHERE EMPNAME = 'NAME1'"); //doesnt work,com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name ''EMP_SCHEMA'.dbo.JOB'. error at line: 14 sql.execute("DELETE FROM [EMP_SCHEMA].[dbo].[JOB] WHERE EMPNAME = 'NAME1'"); //works Dont know how to pass the schema value to SQL querySolved3.8KViews0likes9Comments