rename()

Read(319) Label: table sequence, field, rename,

Here’s how to use rename() function.

T .rename()

Description:

Rename the fields in a table sequence/composite table.

Syntax:

T.rename (F, F')

Note:

The function renames F field as F', or renames a composite table’s index.

Parameters:

F

Field name/index name

F'

The modified field name; when omitted, the original field names will be deleted and replaced by _1, _2…

T

Table sequence/Composite table

Return value:

Table sequence T with modified field names

Example:

 

A

 

1

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

 

2

=A1.rename(EID:ID)

 

3

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

 

4

=A3.create()

Open a composite table

5

=A4.rename(EID:EID2)

Rename EID field EID2

6

=A5.cursor().fetch()

cs.rename()

Description:

Rename a field of a cursor.

Syntax:

cs.rename(F:F',…)

Note:

The function renames F field in cursor cs F', or renames the index of a composite table file.

Parameters:

F

Field name/index name

F'

New name of the field; If omitted, delete the original names and name the fields _1,2...

cs

A cursor

Return value:

A cursor with new field name(s)

Example:

 

A

 

1

=demo.cursor("select EID,NAME,GENDER from employee")

Return a cursor

2

=A1.rename(EID,NAME,GENDER).fetch()

Since parameter is omitted, delete the original field names and name them _1, _2, _3

3

=A1.rename(EID:ID).fetch()

Rename EID field ID

4

=A1.rename(EID:ID,GENDER:SEX,DEPT).fetch()

Rename EID field ID and GENDER field SEX