How to escape semicolon in a string literal in queries | Community
Skip to main content
Level 3
March 18, 2025
Solved

How to escape semicolon in a string literal in queries

  • March 18, 2025
  • 1 reply
  • 622 views

Hi 

This seems like a pretty stupid question, but I am stumped.

I am writing some queries in Adobe Experience Platform, and I want to use a string literal in a SELECT, which includes a semicolon. Something like this:

 

select 'Test with a semicolon;' 

I get this error:

[Code: 0, SQL State: 42601] ERROR: line 1:8: no viable alternative at input 'select ''

It looks like the semicolon in the string literal is read as a command terminator, and anything after it is ignored, hence the syntax error.

I tried a number of ways to escape the semicolon, but nothing worked so far.

 

Any help will be really appreciated. Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by supratim320

Agree with you! I can see in log how the ':' is breaking apart the query. I tried with the common ones and the ascii value conversion works

Ascii of semicolon: 59, hence

SELECT CONCAT('Test with a semicolon ', CHR(59)) AS output;

See if it helps!

1 reply

supratim320Accepted solution
Level 5
March 19, 2025

Agree with you! I can see in log how the ':' is breaking apart the query. I tried with the common ones and the ascii value conversion works

Ascii of semicolon: 59, hence

SELECT CONCAT('Test with a semicolon ', CHR(59)) AS output;

See if it helps!