Was this helpful?
String Literals
Embedded SQL string literals are delimited by single quotes. To embed a single quote in a string literal you should double it, as in:
exec sql insert
        into people (age, surname)
        values (15, 'O''Hara');
String literals cannot be continued over multiple lines.
String Literals and Statement Strings
The Dynamic SQL statements prepare and execute immediate both use statement strings, which specify an SQL statement. The statement string can be specified by a string literal or character string variable, as in:
exec sql execute immediate 'drop employee';
str = 'drop employee';
exec sql execute immediate :str;
As with regular Embedded SQL string literals, the statement string delimiter is the single quote. However, quotes embedded in statement strings must conform to the runtime rules of SQL when the statement is executed. Notice the doubling of the single quote in the following Dynamic insert statement.
exec sql prepare s1 from
   'Insert into t1 values (''single''''double" '')';
The runtime evaluation of the above statement string is:
Insert into t1 values ('single''double" ')
Last modified date: 11/28/2023