简体   繁体   English

org.postgresql.util.PSQLException:错误:“ $ BODY $或附近的不加引号的字符串

[英]org.postgresql.util.PSQLException: ERROR: unterminated dollar-quoted string at or near "$BODY$

I am trying to use dbunit-express in my java project to create some tables and functions on postgress in Junit tests. 我正在尝试在Java项目中使用dbunit-express在Junit测试中的postgress上创建一些表和函数。

I use this driver : 我使用这个驱动程序:

<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>

The java class... Java类...

@Rule 
public EmbeddedDbTesterRule testDb = new EmbeddedDbTesterRule(); // with this you don't neet to call onSetup

@Test
public void testIt() throws Exception {

    try {
        DatabaseCreator databaseCreator = new DatabaseCreator();
        databaseCreator.setDdlFile("HistoryTables.ddl");
        databaseCreator.doCreateDbSchemaFromDdl(testDb.getSqlConnection());
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}

But I get this error... 但是我得到这个错误...

org.postgresql.util.PSQLException: ERROR: unterminated dollar-quoted string at or near "$BODY$ org.postgresql.util.PSQLException:错误:“ $ BODY $或附近的不加引号的字符串

The function looks like this. 该函数如下所示。

CREATE OR REPLACE FUNCTION product_history()
RETURNS trigger AS
$BODY$
BEGIN
INSERT INTO product_history (id, product_id, edit_ts, name, print_provider_id,     description)
    VALUES (nextval('product_history_sequence'), OLD.id, now(), OLD.name,     OLD.print_provider_id, OLD.description);
RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql;

The create works fine in PGAdmin 1.14.3 and in DBVisualizer 9.0.8 在PGAdmin 1.14.3和DBVisualizer 9.0.8中,创建工作正常

Is the create function code included in HistoryTables.ddl ? create function代码是否包含在HistoryTables.ddl If yes the error might be caused by a limitation of DatabaseCreator . 如果是,则错误可能是由于DatabaseCreator的限制引起的。 It splits statements read from the ddl file at ; 它将从ddl文件读取的语句拆分为; (see line 127 of the source code . The function is therefore splitted into multiple statements disturbing the syntax. (请参见源代码的第127行 。因此,该函数被拆分为多个干扰语法的语句。

Try to move the function code into an extra file and send this file as one statement to your server. 尝试将功能代码移到一个额外的文件中,然后将该文件作为一条语句发送到您的服务器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Liquibase 错误 [Postgresql]:&quot;$BODY$&quot; 处或附近未终止的美元引号字符串 - Liquibase error [Postgresql]: unterminated dollar-quoted string at or near "$BODY$ 错误:“$BODY$”处或附近的未终止的美元引号字符串 - ERROR: unterminated dollar-quoted string at or near "$BODY$ “$$”处或附近的未终止的美元引号字符串 - Unterminated dollar-quoted string at or near "$$ psycopg2在“ $ body $”或附近引发未终止的美元报价字符串错误 - psycopg2 throws unterminated dollar-quoted string error at or near “$body$” 从Spring应用执行sql文件时,在“ $$ DECLARE”处或附近出现PSQLException不加终止符的美元报价字符串 - PSQLException unterminated dollar-quoted string at or near "$$ DECLARE while executing sql file from spring app org.postgresql.util.PSQLException:未终止的字符串文字 - org.postgresql.util.PSQLException: Unterminated string literal org.postgresql.util.PSQLException:错误:语法错误在“$ 1”或附近 - org.postgresql.util.PSQLException: ERROR: syntax error at or near “$1” org.postgresql.util.PSQLException:错误:“ 7”或附近的语法错误 - org.postgresql.util.PSQLException: ERROR: syntax error at or near “7” org.postgresql.util.PSQLException:错误:“用户”处或附近的语法错误 - org.postgresql.util.PSQLException: ERROR: syntax error at or near “user” 引起:org.postgresql.util.PSQLException:错误:“:”处或附近的语法错误 - Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near ":"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM