Was this helpful?
String Literals
Use single quotes to delimit Embedded SQL string literals. To embed a single quote in a string literal, use two single quotes, for example:
 exec sql update employee 
1   set comments ='Doesn''t seem to relax' 
2   where eno   = :numvar
You can continue string literals over multiple lines. Following Fortran rules, if the continued line ends without a closing quotation mark, the continuation line must follow the rules for continuation markers. The first character after the continuation marker is considered part of the string literal. For example:
 exec sql update employee 
1   set comments = 'Completed all projects on time. 
2   Recommended for promotion.' 
3   where ename  = 'Jones'
Do not place comment lines between string literal continuation 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, for example:
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 SQL runtime rules when the statement is executed. Notice the doubling of the single quote in the following dynamic insert statement:
exec sql prepare s1 from
1 'Insert into t1 values (''single''''double"'')'
The runtime evaluation of the previous statement string is:
Insert into t1 values ('single''double"')
which inserts the single'double" value into t1.
Last modified date: 04/03/2024