7. Embedded SQL for Pascal : Embedded SQL Statement Syntax for Pascal : 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, 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" ')