Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I get the following error when trying to create a trigger on postgres via dbdeploy. The issue seems to be a postgres jdbc issue rather than dbdeploy. The sql statement seems to be ignored after the first semi-colon in the sql block. Any help with getting past this problem is appreciated.

The sql string (which works perfectly via pgAdmin):

    CREATE FUNCTION trigger_history() RETURNS trigger
        LANGUAGE plpgsql
        AS $$
    BEGIN
        INSERT INTO table_history(col_one, col_two)
        VALUES(NEW.col_one, OLD.col_two);
        RETURN NEW;
    END
    $$;

The error:

Caused by: org.postgresql.util.PSQLException: ERROR: unterminated dollar-quoted string at or near "$ BEGIN INSERT INTO table_history(col_one, col_two) VALUES(NEW.col_one, OLD.col_two)"
  Position: 97
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
share|improve this question

1 Answer 1

I think it's the semicolon causing the problem: $$; just delete it, or move it to the next line. The $$ needs to be at the end of the line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.