SqlPlus - SqlPlus Command

> Procedural Languages > (SQL Plus|SqlCl) (Oracle Database Console)

1 - Syntax

sqlplus username/[email protected] command

where:

  • username is the database login name
  • password is the password. If the password contains an ampersand, you can escape it like this \”[email protected]\”
  • identifier is a connect identifier
  • command, generally @script.sql
Advertising

3 - How to start SQLPlus

3.1 - Maven

<plugin>
		<groupId>org.codehaus.mojo</groupId>
		<artifactId>exec-maven-plugin</artifactId>
		<version>${maven_exec_plugin_version}</version>
		<executions>
			<execution>
				<phase>process-resources</phase>
				<goals>
					<goal>exec</goal>
				</goals>
			</execution>
		</executions>
		<configuration>
			<executable>sqlplus</executable>
			<!-- where the SQL script is run from -->
			<workingDirectory>/Path</workingDirectory>
			<!-- set env variables -->
			<environmentVariables>
				<ORACLE_HOME>/oracle/product/10.1.3.1/OracleAS_1</ORACLE_HOME>
				<PATH>$PATH:$ORACLE_HOME/bin:$JAVA_HOME/bin</PATH>
				<LD_LIBRARY_PATH>$LD_LIBRARY_PATH:$ORACLE_HOME/lib</LD_LIBRARY_PATH>
				<PATH>$PATH:$ORACLE_HOME/bin</PATH>
			</environmentVariables>
			<!-- arguments to be passed to SQLPLUS -->
			<arguments>
				<argument>user/[email protected]:1521/ORCL</argument>
				<argument>@release/RollbackAndInstallReleases.sql</argument>
			</arguments>
		</configuration>
</plugin>

3.2 - Jenkins

sqlplus %SQL_USER%/\"%SQL_PWD%\"@localhost:1521/ORCL @execution.sql 2>&1 output.txt

where:

  • %SQL_USER% and %SQL_PWD% are environment variable created by the Jenkins Credential Manager
lang/sqlplus/sqlplus.txt · Last modified: 2017/09/06 19:29 by gerardnico