> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexagon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# runScript

> Executes a SQL script or Sequence file with one or more SQL file. Property replacement is performed on the files before they are executed. Delimiting

Executes a SQL script or Sequence file with one or more SQL file. Property replacement is performed on the files before they are executed.

> [!NOTE]
>
> ### Delimiting SQL files
>
> Please note that the statements in the SQL files must be delimited properly.
>
> * Use ; to delimit individual statements.
>
> * Use / on new line to delimit program blocks.
>
> * Use /\* or -- (two dashes) for comments.

The SQL Databases supported  by the parser are:

* Oracle 10g+

  * Using statement delimiter of ;

  * PL/SQL blocks starting with DECLARE or BEGIN and finishing with END; /

* MySql 5.1+

* PostgreSql 9.0+ 

* Derby 10.8.2.2+

* SAP HANA

* SQL Server 2008+

* MariaDB 10.0+

* Vertica 6.5+

* H2 1.2.137+

* solidDB 6.5+

* SQL Azure

* DB2 9.7+

* AWS Redshift

* Hsql 1.8+

* Sybase ASE12.5+

* SQLite 3.7.2+

* DB2 z/OS 9.1+

* EnterpriseDB 9.4+

* Phoenix 4.2.2+

* Greenplum 4.3+

No JDBC drivers are included in the plugin.

# Target Properties

<table><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><th>**Property Name**</th><th>**Property Code**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>JDBC URL</td><td>`FDJDBC_URL`</td><td>Yes</td><td>The JDBC URL of the database.\
Connecting to Oracle Autonomous DatabaseYou will need client credential zip file (wallet) to connect with Oracle Autonomous Database on Oracle cloud. You can download wallet zip file from Oracle Cloud, you will need admin userid and password to perform this download. See [Download Client Credentials (Wallets)](https://docs.oracle.com/en-us/iaas/autonomous-database/doc/download-client-credentials.html) for more details on how to download wallet file.<ul><li>**Since FlexDeploy 9.0.0.9 with Oracle Wallet Credential Type :** Instead of maintaining the wallet zip file under the file system, you can now store the wallet zip as an Oracle Credential Type in FlexDeploy. This allows for secure storage and use of the wallet.<ul><li>Use the URL syntax in the following format: `jdbc:oracle:thin:@service_low?TNS_ADMIN={{FDORACLE_WALLET_FILE}}` is replaced with the temporary wallet folder path during execution. Once execution is completed, the temporary file is cleaned up automatically.</li></ul></li><li>**Before FlexDeploy 9.0.0.9**<ul><li>You must make sure that only authorized users have access to these wallet files. Unzip the client credentials zip file (**wallet\_*****databasename*****.zip**) on FlexDeploy server and/or endpoint where it will be used. For example, /home/flexdeploy/.wallets/\<**wallet\_*****databasename***> is folder where specific wallet file was unzipped. Make sure to secure this folder to FlexDeploy and/or Endpoint user, so that it is not readable by all users.</li><li>We recommend using Oracle Wallet Credential Type for better security and easier management of Wallet usage.</li><li>**Database URL Syntax **: jdbc:oracle:thin:@service\_high?TNS\_ADMIN=/home/flexdeploy/.wallets/\<**wallet\_*****databasename***><ul><li>service\_high is one of the entries in the tnsnames.ora file where client credentials zip file was unzipped. See [Predefined Database Service Names for Autonomous Database](https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/connect-predefined-generic.html) for details on services.</li><li>TNS\_ADMIN value in URL points to the location of the **unzipped client credentials zip file**.</li></ul></li><li>**Database URL Long Connection String Format Syntax **: `jdbc:oracle:thin:@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=<hostname>))(connect_data=(service_name=<serice_name>))(security=(ssl_server_cert_dn="CN=<hostname>,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))`<ul><li>Examples for the same can be found [here](https://www.oracle.com/database/technologies/java-connectivity-to-atp.html).</li></ul></li></ul></li></ul>If using the Oracle Database Plugin with ADW or ATP databases , use the \_low connection. The \_medium and \_high connections can sometimes throw error** ORA-12839: cannot modify an object in parallel after modifying it.**</td></tr><tr><td>Oracle Wallet File</td><td>`FDORACLE_WALLET_FILE`</td><td>No</td><td>**Since 9.0.0.9** - Provide the Oracle Wallet file, see[Credential Type - Oracle Wallet](https://docs.flexagon.com/flexdeploy-10-0-documentation/flexdeploy-users-guide/administration/credentials/credential-types/credential-type-oracle-wallet.md) for more details.</td></tr><tr><td>JDBC User</td><td>`FDJDBC_USER`</td><td>No</td><td>The username that will be used to connect with.</td></tr><tr><td>JDBC Password</td><td>`FDJDBC_PASSWORD`</td><td>No</td><td>The password of the username.</td></tr><tr><td>JDBC Driver Path</td><td>`FDJDBC_DRIVER_PATH`</td><td>Yes</td><td>Classpath for locating the JDBC Driver. For example, /u01/oracle/fmw/oracle\_common/modules/oracle.jdbc\_11.2.0/ojdbc6.jar</td></tr></tbody></table>

# Inputs

<table><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><th>**Input Name**</th><th>**Input Code**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>User</td><td>`FDJDBC_INP_USER`</td><td>No</td><td>The username that will be used for database connection. Required if Target JDBC User property is not specified.This input takes precedence over the Target JDBC User property.</td></tr><tr><td>Password</td><td>`FDJDBC_INP_PASSWORD`</td><td>No</td><td>Password for User specified in plugin input. Required if Target JDBC Password property is not specified.This input takes precedence over the Target JDBC Password property.</td></tr><tr><td>Script File</td><td>`FDJDBC_INP_FILE_NAME`</td><td>Yes</td><td>Fully qualified or relative path to script file. If relative path is given, it will be assumed to be in the FD\_ARTIFACTS\_DIR.Script file can be SQL file or Sequence file with one or more SQL file.Property replacement is performed on the files before they are executed.Sequence file is useful to run more than one SQL file in specific sequence. Sequence file must have !SEQ on first line. Each additional line should indicate SQL files as relative path to Sequence file.<pre>!SEQ
CreateHR.sql
GrantHR.sql
ADFStateMgt.sql</pre>Statements in the SQL files must be delimited properly.Delimiting SQL filesPlease note that the statements in the SQL files must be delimited properly.<ul><li>Use ; to delimit individual statements.</li><li>Use / on new line to delimit program blocks.</li><li>Use /\* or -- (two dashes) for comments.</li></ul>\
</td></tr><tr><td>Run Destructive</td><td>`FDJDBC_INP_RUN_DESTRUCTIVE`</td><td>No</td><td>This input allows a mechanism for disallowing certain destructive SQL commands**.**If the input is set to true, `DROP`, `DELETE`, and `TRUNCATE` will be allowed within the script.If the input is set to false, plugin operation will abort with a validation error prior to running any of the commands in the script.This check cannot stop malicious actors, but instead helps to provide some security against accidental running of destructive commands. It is up to the customer to decide whether they want to allow such commands.</td></tr><tr><td>Ignore Compilation Warnings</td><td>`FDJDBC_INP_IGNORE_WARNING`</td><td>No</td><td>If checked, sql compilation warnings will be ignored. Otherwise, they will cause the execution to be marked as failed.For Oracle database, plugin will print errors from USER\_ERRORS or DBA\_ERRORS for the object being deployed. Plugin will read errors from USER\_ERRORS first and then read from DBA\_ERRORS if nothing found. </td></tr><tr><td>Show DBMS Output</td><td>`FDJDBC_INP_SHOW_DBMS_OUT`</td><td>No</td><td>Print DBMS Output in the log. Only supported for Oracle Database. </td></tr><tr><td>Sql Output Length</td><td>`FDJDBC_INP_SQL_OP_LINES`</td><td>No</td><td>Specify the number of sql output lines to be printed on the logs .</td></tr></tbody></table>

# Artifacts

This operation consumes one or more SQL files, and an optional sequence file, from the artifacts repository.

# Endpoint Selection

This operation delegates the selection to the workflow developer to determine.

# Endpoint Execution

This operation will randomly execute on one of the endpoint identified during selection.

# Special Considerations

## Replacement Properties

The SQL files are pre-processed by the plugin to transform any defined [replacement properties](https://flexagon.atlassian.net/wiki/spaces/FD10/pages/11845810449/Property+Replacement+Support).  An example usage of replacement properties is when the schema name cannot be hard-coded because it varies from environment to environment.

## Alternative to Property Replacement

As an alternative to property replacement for dynamic schema injection, consider the use of an `ALTER SESSION` command to modify the schema user which will run the statements.  With this approach you need to ensure that the statements are **not** schema qualified. 

##### **For example, you could add one line to the beginning of your sql files**

```
ALTER SESSION SET current_schema=${{MYINST:MYSCHEMA}} 
```

Where `MYSCHEMA` is a Target property for the `MYINST` instance.  To achieve this you would create a Target-scoped property on the workflow and associate the workflow to the `MYINST` instance.  You will then be able to provide values for each environment associated to that instance.

## Sample SQL script file

```
CREATE OR REPLACE PACKAGE emp_mgmt AS
   FUNCTION hire (last_name VARCHAR2, job_id VARCHAR2, 
      manager_id NUMBER, salary NUMBER, 
      commission_pct NUMBER, department_id NUMBER) 
      RETURN NUMBER; 
   FUNCTION create_dept(department_id NUMBER, location_id NUMBER) 
      RETURN NUMBER; 
   PROCEDURE remove_emp(employee_id NUMBER); 
   PROCEDURE remove_dept(department_id NUMBER); 
   PROCEDURE increase_sal(employee_id NUMBER, salary_incr NUMBER); 
   PROCEDURE increase_comm(employee_id NUMBER, comm_incr NUMBER); 
   no_comm EXCEPTION; 
   no_sal EXCEPTION; 
END emp_mgmt;
/
grant execute on emp_mgmt to HR;

grant execute on dept_mgmt to HR;
```
