header
header
Main Menu
Home
Eviware Store
Downloads
Products
News
Forum
Eviware Blog
Search
FAQs
Customer Area
Support
Documentation
Tutorials
CookBook
Downloads
Forum
Login Form
Welcome, Guest. Please login or register.
December 04, 2008, 10:40:03 pm
Username: Password:
Login with username, password and session length

Forgot your password?
 
Groovy Script SQL - Problems with the assignment of variables
Welcome, Guest. Please login or register.
December 04, 2008, 10:40:03 pm
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  Groovy Script SQL - Problems with the assignment of variables
« previous next »
Pages: [1] Print
Author Topic: Groovy Script SQL - Problems with the assignment of variables  (Read 354 times)
Juergen
Newbie
*
Posts: 6


« on: November 29, 2007, 04:19:20 pm »

I have the following problem I liked to select from a data bank a Sequence TEST_CASE_ID_SEQ and write this afterwards
in another table. Unfortunately, the handing over of the variable TEST_CASE_ID_SEQ into the variable TEST_CASE_ID does not work.
However, I get only the value 'null' I have written the following script.

What do I make wrong ??

##########################
import java.sql.Connection
import java.sql.DriverManager
import javax.sql.DataSource
import groovy.sql.Sql
import oracle.jdbc.driver.OracleTypes
import groovy.sql.DataSet


def driver = oracle.jdbc.driver.OracleDriver
def sql = Sql.newInstance ('jdbc:oracle:thin:pt_xxx/pt_xxx@localhost:31521:pt_xxx')

def TEST_CASE_ID_SEQ
def TEST_CASE_ID

//READ next Value of TEST_CASE_ID_SEQ
TEST_CASE_ID = sql.eachRow("SELECT TEST_CASE_ID_SEQ.nextval as TEST_CASE_ID_SEQ from dual")
{
}

println TEST_CASE_ID
// result null

//Write Value TEST_CASE_ID
//TEST_CASE_ID = "2345"
sql.execute("Insert into log TEST_CASE_ID values (?)", [TEST_CASE_ID])
#####################

Thanks and best regards

Juergen
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,506


« Reply #1 on: November 29, 2007, 07:59:16 pm »

Hi Juergen,

I think the problem is the statement

//READ next Value of TEST_CASE_ID_SEQ
TEST_CASE_ID = sql.eachRow("SELECT TEST_CASE_ID_SEQ.nextval as TEST_CASE_ID_SEQ from dual")
{
}

please try the following instead:

sql.eachRow("SELECT TEST_CASE_ID_SEQ.nextval as TEST_CASE_ID_SEQ from dual")
{
    row -> TEST_CASE_ID = row[0]
}

Hope this helps!

regards,

/Ole
eviware.com
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
header header
header
header