reset()

Read(635) Label: reset,

Here’s how to use reset() function.

cs.reset()

Description:

Reset a cursor by moving it back to the beginning.

Syntax:

cs.reset()

Note:

The function resets a cursor by moving it back to the beginning when it traverses cursor data to the end.

Parameters:

cs

A cursor

Return value:

The cursor itself

Example:

 

A

 

1

=demo.cursor("select * from scores")

Return retrieved data as a cursor

2

=A1.fetch()

Fetch data from the cursor

3

=A1.fetch()

Return null because A1’s cursor has come to the end of the data

4

=A1.reset()

Move the cursor back to the beginning

5

=A1.fetch()

Fetch data out of the cursor; returned result is the same as A2

Related functions:

cs.skip()

f.reset()

Description:

Reorganize a composite table and write it to another composite table file.

Syntax:

f.reset(f’)

f.reset(f’;x)

 

Note:

The function rearranges composite table or multi-zone composite table f and writes it to file or homo-names files group f’, with patch tables merged into it. It reorganizes f itself and re-creates the index when f’ is absent. It changes structure of zone tables when f’ is a homo-names files group; parameter x is the zone table expression.

Parameters:

f

A composite table file/multi-zone composite table/

f’

A composite table file or a homo-name files group

x

Zone table expression

Options:

@u

Write the file as an uncompressed one; perform the write as usual if the parameter is omitted

@z

Write the file as a compressed one; won’t perform compression if the option is absent

@r

Write the file by row; perform the write as usual if the parameter is omitted

@c

Write the file by column

@q

A quick reset

Return value:

Boolean value

Example:

 

A

 

1

=file("D:\\test1.ctx")

An existing composite table file

2

=A1.reset(file("D:\\e1.ctx"))

Copy composite table file test1 to e1.ctx

3

=A1.reset@z(file("D:\\e2.ctx"))

Copy composite table file test1 as a segmented file

4

=A1.reset@c(file("D:\\e3.ctx"))

Copy composite table file test1 as a columwise stored file

5

=A1.reset@u(file("D:\\e4.ctx"))

Copy composite table file test1 as an unsegmented file

6

=A1.reset()

Clear test1.ctx and re-create index for it

7

=A1.reset@r(file("D:\\e5.ctx"))

Copy composite table file test1 as a rowwise stored file

8

=file("D:\\emp12.ctx")

 

9

=A8.open()

Open A8’s composite table file and data in its base table is as follows:

10

=create(EID,NAME).record([4,"Emily"])

11

=A9.delete(A10)

Delete A12’s record from A10’s composite table

12

=A9.close()

Close the composite table

13

=A8.reset@q()

Reset the composite table file

14

=file("emp.ctx":[2,3])

Return a homo-name files group

15

=file("emCp.ctx":[2,3])

 

16

=A14.reset(A15)

Reorganize 2.emp.ctx and 3.emp.ctx in A14’s homo-name files group and write them to 2.empCp.ctx and 3.empCp.ctx respectively in a new files group

 

 

T.reset()

Description:

Clear the members of a table sequence.

Syntax:

T.reset()

Note:

The function clears members from table sequence T, but reserves the data structure.

Parameters:

T

A table sequence

Return value:

The empty table sequence T.

Example:

 

A

 

1

=demo.query("select * from EMPLOYEE")

2

=A1.reset()