4. Embedded SQL for Fortran : Embedded SQL Statement Syntax for Fortran : String Literals : String Literals and Statement Strings
 
Share this page                  
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.