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

SQL Anywhere 11.0.1 (中文) » UltraLite - M-Business Anywhere 编程 » 了解 UltraLite for M-Business Anywhere 开发 » 使用 Table API 处理数据

 

使用 Table API 导航

UltraLite for M-Business Anywhere 为您执行各种各样的导航任务提供了许多在表中导航的方法。

使用 ULTable 对象的以下方法,您可以在结果集中导航:

  • moveAfterLast   移至最后一行之后的位置。

  • moveBeforeFirst   移至第一行之前的位置。

  • moveFirst   移至第一行。

  • moveLast   移至最后一行。

  • moveNext   移至下一行。

  • movePrevious   移至上一行。

  • moveRelative   相对于当前行移动一定数量的行。正索引值在表中向前移动,负索引值在表中向后移动,零不移动游标。如果要重新填充行缓冲区,可以使用零。

示例

以下代码打开 customer 表并在其行间滚动。然后,它会显示一个警告,其中包含每个客户的姓氏。

var tCustomer;
tCustomer = conn.getTable( "customer", null );
tCustomer.open();
tCustomer.moveBeforeFirst();
While (tCustomer.moveNext()) {
  alert( tCustomer.getString(3) );
}
指定索引

打开表对象时,应用程序可以访问表中的行。缺省情况下,这些行按主键值顺序访问,但您可以指定索引,以便以某种顺序访问行。

示例

以下代码会移动到按 ix_name 索引排序的 customer 表的第一行。

tCustomer = conn.getTable("customer", null );
tCustomer.openWithIndex("ix_name");
tCustomer.moveFirst();