Problem
We have a DBA provided wrapper script that is used to execute a number of underlying sql scripts which comprise a given software release.
The wrapper script outputs some debug information about what will be executed then asks the user if they wish to continue, using the following sqlplus command
ACCEPT DB_OK PROMPT "Do you wish to Continue Y/[N]? : " DEFAULT N
We’re trying to automate the database creation in our build using maven…the build hangs waiting for user input 🙁
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sqlplus</executable>
<arguments>
<argument>${db.user}/${db.password}@${db.service.name}</argument>
<argument>@${project.build.directory}/test-resources/create-db.sql</argument>
</arguments>
<workingDirectory>${project.build.directory}/test-resources</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
Attempted Solutions
I’ve attempted to wrap the ACCEPT call in a plsql IF/ELSE block but this leads to an error regarding ‘ACCEPT’ and incorrect syntax, I guess this is because I’m mixing plsql and sqlplus commands.
Question
So, does anyone know how I can disable the ACCEPT prompt in sqlplus akin to SET DEFINE OFF for traditional substitution variables?
I can make small modifications to the wrapper script but the DBA’s would probably complain if I were to do a bulk refactor.
Thanks.
SQL*Plus uses positional notation to pass parameters. So this would pass
42as the first (and only) parameter expected bysome_script.sqlThis would short-circuit any ACCEPT call.
So, if I have correctly understood how your Maven plugin works, I think you can achieve the same thing like this:
That is, pass
Yas the next argument in the sqlplus command string (assumingDB_OKis the first expected parameter – you’ll know your scripts better than I).