Liquibase : unterminated dollar-quoted string at or near $BODY$

Viewed 2255

Hi I'm struggling with the issue from the topic. I have the following changeset:

 <changeSet author="artur" id="storedProcedures-0003">

        <sqlFile dbms="postgresql"
                 encoding="utf8"
                 path="server/sql/storedProcedures/postgresql/procedure.sql"
                 relativeToChangelogFile="true"
                 splitStatements="false"
        />
    </changeSet>

My procedure is :

CREATE FUNCTION testProc(oRefCursor          OUT  REFCURSOR)

AS $BODY$
DECLARE
    minLevel        INTEGER;
    defDcId         DECIMAL(19);
BEGIN

END;
$BODY$ LANGUAGE plpgsql;

This procedure works fine with pgAdmin tool, but in liquibase i always got the error. I was trying to find and answer but nor this and this works for me. I have this procedure in seprate file, I use a splitStatements="false" but nothing helps. I always get this error. Does anyone know a workaround for this issue (is this Liquibase issue ?). I was trying to write this in one line, i was trying use a slashes but without success.

2 Answers

A very good workaround for liquibase is to use a different delimiter. My personal choice is just double semicolon.

CREATE FUNCTION exampleFunction()
AS
$BODY$
BEGIN
    SELECT 1;
END;
$BODY$ 
    LANGUAGE plpgsql;;
<changeSet id="1" author="author">
    <sqlFile path="example.sql" endDelimiter=";;"/>
</changeSet>
Related