# liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9 \[Failed SQL

**URL:** <https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284>\
**Category:** Liquibase Development\
**Created:** [April 16, 2024, 1:07am UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284 "2024-04-16T01:07:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sheshank](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Sheshank](https://forum.liquibase.org/u/Sheshank)\
**Post date:** [April 16, 2024, 1:07am UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/1 "2024-04-16T01:07:47Z")

</div>

We’re attempting to create a stored procedure using Liquibase scripts… Able to execute DDL, DQL, DML, DCL like queries using liquibase but we’re encountering difficulties creating the stored procedure.  
Below are the screenshots of the XML and SQL files we’re using, and following that is the error trace we’re encountering during execution. Could you please assist us in identifying if we’re overlooking anything in the XML file or elsewhere?  
SQL Version: mysql Ver 8.2.0

Exception Trace:  
Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for change set database/release\_0.0.5.1/changeset/1\_insert\_debug\_log\_proc.xml::release\_0.0.5.1\_1::sheshank@backbase.com:  
Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 9 [Failed SQL: (1064) CREATE PROCEDURE insert\_debug\_log\_proc(  
IN p\_procedure\_name VARCHAR(255),  
IN p\_procedure\_invocation\_id VARCHAR(255),  
IN p\_log\_type VARCHAR(255),  
IN p\_log\_message TEXT  
)  
BEGIN  
INSERT INTO PROCEDURE\_DEBUG\_LOGS (procedure\_name, procedure\_invocation\_id, log\_type, log\_message)  
VALUES (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message)]

Below is my stored procedure.

use `x.......`;

CREATE PROCEDURE insert\_debug\_log\_proc(IN p\_procedure\_name VARCHAR(255),IN p\_procedure\_invocation\_id VARCHAR(255), IN p\_log\_type VARCHAR(255), IN p\_log\_message TEXT)  
BEGIN  
INSERT INTO PROCEDURE\_DEBUG\_LOGS (procedure\_name, procedure\_invocation\_id, log\_type, log\_message) VALUES (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message);  
END;

xml file

 Create debug logs procedure 

Please help me here, unable to resolve this error from so long time

---

<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:** [April 16, 2024, 1:10pm UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/2 "2024-04-16T13:10:54Z")

</div>

It helps to see the entire .xml file, but basically you need to set the endDelimiter for the changeset since Liquibase uses the semicolon by default, which doesn’t work for procedures, functions, packages, etc. It can be any character not in your code.

```auto
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

<changeSet id="create_procedure" author="BOB" runOnChange="true">
  <sql endDelimiter="/">
    create or replace procedure test_proc is
      v_dummy1 date;
    begin
      --This is select 1
      select sysdate into v_dummy1 from "DUAL";
    end test_proc;
    /  
  </sql>
  <rollback>
    DROP PROCEDURE test_proc;
  </rollback>
</changeSet>

</databaseChangeLog>

```

---

<div class="post-metadata">

**Author:** ![Sheshank](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Sheshank](https://forum.liquibase.org/u/Sheshank)\
**Post date:** [April 17, 2024, 5:28am UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/3 "2024-04-17T05:28:27Z")

</div>

\<?xml version="1.0" encoding="UTF-8"?\>

```
<changeSet id="xrelease" author="BOB" runOnChange="true">
    <comment>Create debug logs procedure</comment>
    <sql endDelimiter="/">
        use `custom-schema-dd`;
        create or replace procedure insert_debug_log_proc is
            p_procedure_name VARCHAR(255),
            p_procedure_invocation_id VARCHAR(255),
            p_log_type VARCHAR(255),
            p_log_message TEXT;
        begin
            insert into procedure_debug_logs (procedure_name, procedure_invocation_id, log_type, log_message) values (p_procedure_name, p_procedure_invocation_id, p_log_type, p_log_message);
        end insert_debug_log_proc;
        /
    </sql>
    <rollback>
        <sqlFile path="rback/1_drop_insert_debug_log_proc.sql"/>
    </rollback>
</changeSet>

```

@daryldoak , Made the xml changes as suggested , but still facing below issue after executing.

Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘create or replace procedure insert\_debug\_log\_proc is  
p\_procedure’ at line 2 [Failed SQL: (1064) use `custom-schema-dd`;  
create or replace procedure insert\_debug\_log\_proc is  
p\_procedure\_name VARCHAR(255),  
p\_procedure\_invocation\_id VARCHAR(255),  
p\_log\_type VARCHAR(255),  
p\_log\_message TEXT;  
begin  
insert into procedure\_debug\_logs (procedure\_name, procedure\_invocation\_id, log\_type, log\_message) values (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message);  
end insert\_debug\_log\_proc;]  
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:774) ~[spring-beans-5.3.29.jar:5.3.29]

Please 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:** [April 17, 2024, 1:12pm UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/4 "2024-04-17T13:12:13Z")

</div>

> [@Sheshank](#):
>
> `use `custom-schema-dd`;`

That statement is causing your issue. It is separate statement within the changeset, and since you defined “/” as the end-delimiter for the changeset, that statement must also be delimited with “/”, not semicolon.

---

<div class="post-metadata">

**Author:** ![Sheshank](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Sheshank](https://forum.liquibase.org/u/Sheshank)\
**Post date:** [April 18, 2024, 6:00am UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/5 "2024-04-18T06:00:29Z")

</div>

```
    <sql endDelimiter="/">
        use `custom-schema-dd`
        /
        create procedure insert_debug_log_proc(
            p_procedure_name VARCHAR(255),
            p_procedure_invocation_id VARCHAR(255),
            p_log_type VARCHAR(255),
            p_log_message TEXT
        )

        begin

            insert into procedure_debug_logs (procedure_name, procedure_invocation_id, log_type, log_message) values (p_procedure_name, p_procedure_invocation_id, p_log_type, p_log_message);

        end insert_debug_log_proc;

        /
    </sql>

```

Refracted as above, getting same exception till

Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘insert\_debug\_log\_proc’ at line 9 [Failed SQL: (1064) create procedure insert\_debug\_log\_proc(  
p\_procedure\_name VARCHAR(255),  
p\_procedure\_invocation\_id VARCHAR(255),  
p\_log\_type VARCHAR(255),  
p\_log\_message TEXT  
)  
begin  
insert into procedure\_debug\_logs (procedure\_name, procedure\_invocation\_id, log\_type, log\_message) values (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message);  
end insert\_debug\_log\_proc;]  
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:774) ~[spring-beans-5.3.29.jar:5.3.29]

---

<div class="post-metadata">

**Author:** ![Sheshank](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Sheshank](https://forum.liquibase.org/u/Sheshank)\
**Post date:** [April 18, 2024, 6:04am UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/6 "2024-04-18T06:04:36Z")

</div>

Create debug logs procedure use `custom-schema-dd` / create procedure insert\_debug\_log\_proc is p\_procedure\_name VARCHAR(255), p\_procedure\_invocation\_id VARCHAR(255), p\_log\_type VARCHAR(255), p\_log\_message TEXT; begin insert into procedure\_debug\_logs (procedure\_name, procedure\_invocation\_id, log\_type, log\_message) values (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message); end insert\_debug\_log\_proc; / 

```
<rollback>
    <sqlFile path="rback/1_drop_insert_debug_log_proc.sql"/>
</rollback>

```

Refracted as above.

Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘insert\_debug\_log\_proc’ at line 9 [Failed SQL: (1064) create procedure insert\_debug\_log\_proc(  
p\_procedure\_name VARCHAR(255),  
p\_procedure\_invocation\_id VARCHAR(255),  
p\_log\_type VARCHAR(255),  
p\_log\_message TEXT  
)  
begin  
insert into procedure\_debug\_logs (procedure\_name, procedure\_invocation\_id, log\_type, log\_message) values (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message);  
end insert\_debug\_log\_proc;]  
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:774) ~[spring-beans-5.3.29.jar:5.3.29]

---

<div class="post-metadata">

**Author:** ![Sheshank](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Sheshank](https://forum.liquibase.org/u/Sheshank)\
**Post date:** [April 18, 2024, 12:58pm UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/7 "2024-04-18T12:58:40Z")

</div>

Still facing the same issue after having delimeter at use statement.  
Create debug logs procedure  
  
use `custom-schema-dd`  
/  
create or replace procedure insert\_debug\_log\_proc is  
p\_procedure\_name VARCHAR(255),  
p\_procedure\_invocation\_id VARCHAR(255),  
p\_log\_type VARCHAR(255),  
p\_log\_message TEXT;  
begin  
insert into procedure\_debug\_logs (procedure\_name, procedure\_invocation\_id, log\_type, log\_message) values (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message);  
end insert\_debug\_log\_proc;  
/

Exception:  
Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘insert\_debug\_log\_proc’ at line 9 [Failed SQL: (1064) create procedure insert\_debug\_log\_proc(  
p\_procedure\_name VARCHAR(255),  
p\_procedure\_invocation\_id VARCHAR(255),  
p\_log\_type VARCHAR(255),  
p\_log\_message TEXT  
)  
begin  
insert into procedure\_debug\_logs (procedure\_name, procedure\_invocation\_id, log\_type, log\_message) values (p\_procedure\_name, p\_procedure\_invocation\_id, p\_log\_type, p\_log\_message);  
end insert\_debug\_log\_proc;]  
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:774) ~[spring-beans-5.3.29.jar:5.3.29]

---

<div class="post-metadata">

**Author:** ![Sheshank](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Sheshank](https://forum.liquibase.org/u/Sheshank)\
**Post date:** [April 22, 2024, 10:24am UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/8 "2024-04-22T10:24:00Z")

</div>

@daryldoak Any help here please

---

<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:** [April 25, 2024, 3:01pm UTC](https://forum.liquibase.org/t/liquibase-exception-databaseexception-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your-mysql-server-version-for-the-right-syntax-to-use-near-at-line-9-failed-sql/9284/9 "2024-04-25T15:01:36Z")

</div>

The error is stating that you have a sql syntax error in the procedure:

```auto
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘insert_debug_log_proc’ at line 9 

```

I don’t know anything about mysql, so unfortunately I won’t be able to help with the syntax issue.

I’d recommend removing the “use” statement and focus instead on the procedure. then once the procedure works, add the “use” back in.
