I'm trying to insert a pattern string into the PATTERN_SETTING table in Oracle using the following SQL:
INSERT INTO PATTERN_SETTING (ID, NAME, PATTERN)
VALUES (30, 'Alphanumeric and symbol', '^[a-zA-Z0-9!"#$%&''()*+,\-./:;<=>?@\\[\\]^_`{|}~]+$');
When I run this SQL in IntelliJ IDEA’s DB tool, it works perfectly. However, when I try to execute the same script via Jenkins, I get the following error:
INSERT INTO PATTERN_SETTING (ID, NAME, PATTERN)
VALUES (30, 'Alphanumeric and symbol', '^[a-zA-Z0-9!\"#$%&''()*+,\-./:
[WARN] code :1756
java.sql.SQLSyntaxErrorException: ORA-01756: quoted string not properly terminated
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:202)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:45)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:933)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1075)
at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1640)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1603)
at oracle.jdbc.driver.OracleStatementWrapper.executeUpdate(OracleStatementWrapper.java:308)
at com.tcg.sql.patch.DbScriptsExecutor.runScript(DbScriptsExecutor.java:212)
at com.tcg.sql.patch.DbScriptsExecutor.integrate(DbScriptsExecutor.java:168)
at com.tcg.sql.patch.DbScriptsExecutor.patch(DbScriptsExecutor.java:121)
at com.tcg.sql.patch.DbScriptsExecutor.execute(DbScriptsExecutor.java:72)
at com.tcg.sql.patch.DBPatchRunner.run(DBPatchRunner.java:49)
at com.tcg.sql.patch.Main.entry(Main.java:19)
at com.tcg.sql.patch.Main.main(Main.java:35)
It seems like the special characters in the PATTERN column may be causing issues during script execution in Jenkins. How can I resolve this issue?
I’ve already tried escaping single quotes by doubling them (e.g., ''), but the error persists in Jenkins. Any ideas on how to handle this?
;as a statement delimiter, and that needs to be escaped when you include it in the SQL.