Liquibase endDelimiter usage

2.2k views Asked by At

Trying to run this from Liquibase:

--changeset blah runOnChange:true endDelimiter:\n/\s*\n|\n/\s*$
DELETE MYTABLE;
INSERT INTO MYTABLE(A,B,C) VALUES ('A', 'B', 'C');

DECLARE
  row_count NUMBER;
BEGIN
  SELECT COUNT(1) INTO row_count FROM OTHERTABLE;
  IF (row_count = 0)
    THEN DELETE MYTABLE WHERE A LIKE 'BLAH:%';
  END IF;
END;
/

But getting this error:

Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

Seems this works in these cases:

  1. With just the insert/delete (no declare statement block) and without the endDelimiter statement
  2. With just the declare statement block (no insert/delete) and with the endDelimiter statement

But it doesn't work all together. ??

1

There are 1 answers

1
coco On BEST ANSWER

try

DECLARE
  row_count NUMBER;
BEGIN
    DELETE MYTABLE;
    INSERT INTO MYTABLE(A,B,C) VALUES ('A', 'B', 'C');

  SELECT COUNT(1) INTO row_count FROM OTHERTABLE;
  IF (row_count = 0)
    THEN DELETE MYTABLE WHERE A LIKE 'BLAH:%';
  END IF;
END;

or with a "/" after each statement