Forum Discussion

Wouter's avatar
Wouter
New Contributor
8 years ago
Solved

SQL where in groovy script

Hi,

 

The following groovy script does nothing:

 

 

def cmd = /sqlcmd -S 127.0.0.1\MSSQLSERVER -d LocalDevelop10DB -Q "DELETE FROM T_TimeRegistration WHERE TimeRegLineNr > 36"/
cmd.execute()

 

 

While this groovy script works perfectly:

 

def cmd = /sqlcmd -S 127.0.0.1\MSSQLSERVER -d LocalDevelop10DB -Q "DELETE FROM T_TimeRegistration WHERE TimeRegLineNr = 37"/
cmd.execute()

I want to use the (effects of) first script. It seems the '>' character is somehow not supported, I tried escaping it but no joy. What am I missing, can someone help?

 

Thanks

  • Do you need to fire off the query within a Groovy script? Seems like a lot to manage when ReadyAPI has a built-in JDBC request test step to handle all of this. I've had success building my query in a  Groovy script then passing this string to the query of a JDBC request step.

3 Replies

    • JustinM89's avatar
      JustinM89
      Contributor

      Do you need to fire off the query within a Groovy script? Seems like a lot to manage when ReadyAPI has a built-in JDBC request test step to handle all of this. I've had success building my query in a  Groovy script then passing this string to the query of a JDBC request step.

      • Wouter's avatar
        Wouter
        New Contributor

        Thanks for the reply, I got it working in the meantime with BETWEEN sql keyword.

        When I need more SQL stuff I will give the JDBC connection a go, thanks.