How to set up the SQL statement when calling ant sql task?


(Sergei Kobiakov) #1

I got some gradle code that executing the *.sql file:

ant.sql(classpath: configurations.driver.asPath,
   driver: oraProp.getProperty('db.driver'),
   encoding: oraProp.getProperty('db.encoding'),
   url: oraProp.getProperty('db.url'),
   userid: oraProp.getProperty('db.user.name'),
   password: oraProp.getProperty('db.user.password'),
   onerror: 'continue') {
  fileset(file: 'tests/cfg/scripts/clean.sql')
 }

I want to modify it that instead of the *.sql file, the statement was String or something close, something like:

ant.sql(classpath: configurations.driver.asPath,
   driver: oraProp.getProperty('db.driver'),
   encoding: oraProp.getProperty('db.encoding'),
   url: oraProp.getProperty('db.url'),
   userid: oraProp.getProperty('db.user.name'),
   password: oraProp.getProperty('db.user.password'),
   onerror: 'continue') {
  'drop table t_abw_geplant'}

But no idea how to do it(((( I will appreciate any help.


Apply SQL from jar
(Peter Niederwieser) #2

If the Ant SQL task supports this, it will likely be mentioned in its docs.


(Perryn Fowler) #3

I think you want this

ant.sql(classpath: configurations.driver.asPath,
            driver: oraProp.getProperty('db.driver'),
            encoding: oraProp.getProperty('db.encoding'),
            url: oraProp.getProperty('db.url'),
            userid: oraProp.getProperty('db.user.name'),
            password: oraProp.getProperty('db.user.password'),
            onerror: 'continue',
           'drop table t_abw_geplant')

(Sergei Kobiakov) #4

Thank you, it works!!!