Department_of_T
12 years agoContributor
[Res] JDBC wont run in DataGen
Hi All
I have a 'DataGen' with a property called Customer Key which uses a type =SCRIPT. The value is grabbed from the Datasource and then depending on that value, a certain type of SQL is run and the value is set to the result. The problem is that when i click Play to test the DataGEn there are no results returned. If i grab any one of the below SQL statements and create a groovy script and press play then it returns the correct value.
Why wont JDBC queries run in the DataGen?
I have a 'DataGen' with a property called Customer Key which uses a type =SCRIPT. The value is grabbed from the Datasource and then depending on that value, a certain type of SQL is run and the value is set to the result. The problem is that when i click Play to test the DataGEn there are no results returned. If i grab any one of the below SQL statements and create a groovy script and press play then it returns the correct value.
Why wont JDBC queries run in the DataGen?
import groovy.sql.Sql
def value = testRunner.testCase.testSteps["CreateTPValidations DataSource"].getProperty(propertyDSMatrix).getValue()
if (value.equals("Existing Org key")){ //an existing organisation key in Trelis, one not created via AP
def dbTableCommentsQry = """ select * from cli_clients where created_by !='BATCH_USER' and client_type=0 and rownum=1 order by dbms_random.value"""
def sql = Sql.newInstance("jdbc:oracle:thin:@X:1521:X", "X", "X", "oracle.jdbc.driver.OracleDriver")
def res= sql.firstRow(dbTableCommentsQry )
value = res[0]
sql.close()
}
else if (value.equals("New Person key")){ //a new person key, one created via AP, createPerson
def dbTableCommentsQry = """ select * from cli_clients where created_by ='BATCH_USER' and client_type=1 and rownum=1 order by dbms_random.value"""
def sql = Sql.newInstance("jdbc:oracle:thin:@X:1521:X", "X", "X", "oracle.jdbc.driver.OracleDriver")
def res= sql.firstRow(dbTableCommentsQry )
value = res[0]
sql.close()
}
else if (value.equals("New Org key")){ //a new org key, one created via AP, createOrganisation
def dbTableCommentsQry = """ select * from cli_clients where created_by ='BATCH_USER' and client_type=0 and rownum=1 order by dbms_random.value"""
def sql = Sql.newInstance("jdbc:oracle:thin:@X:1521:X", "X", "X", "oracle.jdbc.driver.OracleDriver")
def res= sql.firstRow(dbTableCommentsQry )
value = res[0]
sql.close()
}
else if (value.equals("Existing Person key")){ //an existing person key in Trelis, one not created via AP
def dbTableCommentsQry = """ select * from cli_clients where created_by !='BATCH_USER' and client_type=1 and rownum=1 order by dbms_random.value"""
def sql = Sql.newInstance("jdbc:oracle:thin:@X:1521:X", "X", "X", "oracle.jdbc.driver.OracleDriver")
def res= sql.firstRow(dbTableCommentsQry )
value = res[0]
sql.close()
}