

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » Java in the Database » The runtime environment for Java in the database

Persistence Next Page

Java escape characters in SQL statements

In Java code, you can use escape characters to insert certain special characters into strings. Consider the following code, which inserts a new line and tab in front of a sentence containing an apostrophe.

String str = "\n\t\This is an object\'s string literal";

SQL Anywhere permits the use of Java escape characters only when being used by Java classes. From within SQL, however, you must follow the rules that apply to strings in SQL.

For example, to pass a string value to a field using a SQL statement, you could use the following statement (which includes SQL escape characters), but the Java escape characters could not be used.

SET obj.str = '\nThis is the object''s string field';

For more information on SQL string handling rules, see Strings.