Java プロジェクトで dbunit-express を使用して、Junit テストの postgress でいくつかのテーブルと関数を作成しようとしています。
私はこのドライバーを使用します:
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
ジャバクラスは…
@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());
}
}
しかし、私はこのエラーが発生します...
org.postgresql.util.PSQLException: エラー: "$BODY$ またはその近くにドルで引用された文字列が終了していません
機能はこんな感じ。
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;
create は PGAdmin 1.14.3 および DBVisualizer 9.0.8 で正常に動作します