使用 UltraLite 可以执行 SQL 数据操作语言操作和 DDL 操作。这些操作是使用 ExecuteStatement 方法(PreparedStatement 类的一个成员)执行的。
有关 PreparedStatement 类的详细信息,请参见PreparedStatement 类 [UltraLite for M-Business Anywhere]。
UltraLite 使用 ? 参数标记处理变量值。对于任何 INSERT、UPDATE 或 DELETE 语句,每个 ? 都是根据其在预准备语句中的序号位置引用的。例如,第一个 ? 引用为 1,第二个引用为 2。
声明 PreparedStatement 对象。
var PrepStmt; |
给预准备语句对象指派 INSERT 语句。在以下代码中,TableName 和 ColumnName 是表和列的名称。
PrepStmt = conn.prepareStatement( "INSERT into TableName(ColumnName) values (?)", null ); |
空参数指示该语句没有永久名称。
为该语句指派参数值。
var NewValue; NewValue = "Bob"; PrepStmt.setStringParameter(1, NewValue); |
执行语句。
PrepStmt.executeStatement( null ); |
UltraLite 使用 ? 参数标记处理变量值。对于任何 INSERT、UPDATE 或 DELETE 语句,每个 ? 都是根据其在预准备语句中的序号位置引用的。例如,第一个 ? 引用为 1,第二个引用为 2。
声明 PreparedStatement 对象。
var PrepStmt; |
给预准备语句对象指派 UPDATE 语句。在以下代码中,TableName 和 ColumnName 是表和列的名称。
PrepStmt = conn.prepareStatement( "UPDATE TableName SET ColumnName = ? WHERE ID = ?", null); |
空参数指示该语句没有永久名称。
使用适合于数据类型的方法为该语句指派参数值。
var NewValue; NewValue = "Bob"; PrepStmt.setStringParameter(1, NewValue); PrepStmt.setIntParameter(2, 6); |
执行语句。
PrepStmt.executeStatement( ); |
UltraLite 使用 ? 参数标记处理变量值。对于任何 INSERT、UPDATE 或 DELETE 语句,每个 ? 都是根据其在预准备语句中的序号位置引用的。例如,第一个 ? 引用为 1,第二个引用为 2。
声明 PreparedStatement 对象。
var PrepStmt; |
给预准备语句对象指派 DELETE 语句。
PrepStmt = conn.prepareStatement( "DELETE FROM customer WHERE ID = ?", null ); |
空参数指示该语句没有永久名称。
为该语句指派参数值。
var IDValue; IDValue = 6; PrepStmt.setIntParameter( 1, IDValue ); |
执行语句。
PrepStmt.executeStatement( ); |
![]() |
使用DocCommentXchange讨论此页。
|
版权 © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |