Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - 编程 » 数据库中的 Java » SQL Anywhere 中的 Java 支持 » 数据库中的 Java 的运行时环境

 

SQL 语句中的 Java 转义字符

在 Java 代码中,可以使用转义字符在字符串中插入某些特殊字符。请看下面的代码,该代码在一个包含撇号的句子前面插入一个新行和制表符。

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

只有在 Java 类使用 Java 转义字符时,SQL Anywhere 才允许使用 Java 转义字符。但在 SQL 内,必须遵守适用于 SQL 中的字符串的规则。

例如,要给使用 SQL 语句的字段传递字符串值,您可以使用下面的语句(包括 SQL 转义字符),但不能使用 Java 转义字符。

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

有关 SQL 字符串处理规则的详细信息,请参见字符串