# Executing SQL file from another SQL file

**URL:** <https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942>\
**Category:** Community Answers\
**Created:** [June 10, 2022, 9:55am UTC](https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942 "2022-06-10T09:55:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![b.mohan86](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@b.mohan86](https://forum.liquibase.org/u/b.mohan86)\
**Post date:** [June 10, 2022, 9:55am UTC](https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942/1 "2022-06-10T09:55:28Z")

</div>

Hi everyone,

Could you anyone please help me clarify below scenario in liquibase.

I have an existing application where one sql file is called from another sql file.

“temp\_script.sql” contains

start C:\scripts\temp\_func.sql

“temp\_func.sql” contains

create or replace function temp\_func  
return date  
as  
l\_date date;  
BEGIN  
select sysdate into l\_date from dual;  
return l\_date;  
end;  
/

i have added temp\_script in one of the changeset, but i am getting error during execution

```
<changeSet author="user" id="4" runAlways="true">
 <sqlFile dbms="oracle"
    encoding="UTF-8"
    endDelimiter="\nGO"
    path="../scripts/temp_script.sql"
    relativeToChangelogFile="true"
    splitStatements="true"
    stripComments="true"/>
</changeSet>

```

And the error is

Caused by: java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement

```
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:509)
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:461)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1104)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:550)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:268)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:655)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:229)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:41)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:928)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1205)
    at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1823)
    at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1778)
    at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:303)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:393)
    ... 72 more

```

Caused by: Error : 900, Position : 0, Sql = start C:\scripts\temp\_func.sql, OriginalSql = start C:\scripts\temp\_func.sql, Error Msg = ORA-00900: invalid SQL statement

```
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:513)
    ... 85 more

```

---

<div class="post-metadata">

**Author:** ![daryldoak](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/daryldoak/32/764_2.png) [@daryldoak](https://forum.liquibase.org/u/daryldoak)\
**Post date:** [June 10, 2022, 6:13pm UTC](https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942/2 "2022-06-10T18:13:02Z")

</div>

The problem is your end delimiter. You used a “/” in your .sql, but you defined endDelimiter="\nGO" in your changeset. One or the other needs to be changed so they match.

---

<div class="post-metadata">

**Author:** ![b.mohan86](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@b.mohan86](https://forum.liquibase.org/u/b.mohan86)\
**Post date:** [June 13, 2022, 6:33am UTC](https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942/3 "2022-06-13T06:33:48Z")

</div>

Hi Daryl,

here is the modified code

## Change Set

```
<changeSet author="author" id="4" runAlways="true">
 <sqlFile dbms="oracle"
	relativeToChangelogFile="true"
    path="../scripts/temp_script.sql"
	splitStatements="true"
    stripComments="true"/>
</changeSet>

```

## temp\_script.sql

start C:\scripts\temp\_func.sql;

## temp\_func.sql

create or replace function temp\_func  
return date  
aS  
l\_date date;  
BEGIN  
select sysdate into l\_date from dual;  
return l\_date;  
end;  
/

But sill i am getting the same error:

Starting Liquibase at 11:59:11 (version 4.11.0 #2708 built at 2022-05-23 15:17+0000)  
Liquibase Version: 4.11.0  
Liquibase Community 4.11.0 by Liquibase

Running Changeset: changelog/change\_001.xml::4::author

Unexpected error running Liquibase: ORA-00900: invalid SQL statement

For more information, please use the --log-level flag

---

<div class="post-metadata">

**Author:** ![MikeOlivas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/mikeolivas/32/183_2.png) [@MikeOlivas](https://forum.liquibase.org/u/MikeOlivas)\
**Post date:** [June 14, 2022, 1:44pm UTC](https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942/4 "2022-06-14T13:44:03Z")

</div>

Since / is a default terminator on Oracle but the sql standard is still ; you can change your splitstatements to false. Otherwise it is trying to end the sql statement on the first ; which would be **l\_date date;**

---

<div class="post-metadata">

**Author:** ![b.mohan86](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@b.mohan86](https://forum.liquibase.org/u/b.mohan86)\
**Post date:** [June 15, 2022, 8:41am UTC](https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942/5 "2022-06-15T08:41:32Z")

</div>

Hi,

This is the new changeset.

```
<changeSet author="author" id="4" runAlways="true">
 <sqlFile dbms="oracle"
	relativeToChangelogFile="true"
    path="../scripts/temp_script.sql"
	splitStatements="false"
    stripComments="true"/>
</changeSet>

```

Tried executing, but sorry, it still doesnt work.

Caused by: java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement

```
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:509)
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:461)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1104)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:550)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:268)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:655)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:229)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:41)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:928)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1205)
    at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1823)
    at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1778)
    at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:303)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:393)
    ... 72 more

```

Caused by: Error : 900, Position : 0, Sql = start C:\scripts\temp\_func.sql;, OriginalSql = start C:\scripts\temp\_func.sql;, Error Msg = ORA-00900: invalid SQL statement

```
    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:513)
    ... 85 more

```

Thank you for all the help.

---

<div class="post-metadata">

**Author:** ![daryldoak](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/daryldoak/32/764_2.png) [@daryldoak](https://forum.liquibase.org/u/daryldoak)\
**Post date:** [June 15, 2022, 7:03pm UTC](https://forum.liquibase.org/t/executing-sql-file-from-another-sql-file/6942/6 "2022-06-15T19:03:36Z")

</div>

Since your are executing PL/SQL, and using “/” as the end-delimiter in temp\_func.sql, your changeset needs to set endDelimiter="/". Liquibase is using the default semicolon, which is breaking your PL/SQL into invalid statements, resulting in the ORA-00900.
