rename()

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

Here’s how to use rename() function.

T. rename()

Description:

Rename the fields in a table sequence/(multizone) entity table.

Syntax:

T.rename (F,F',…)

Note:

The function renames F field F', or renames a composite table’s attached table and returns a table sequence with renamed T fields.

Parameter:

F

A field name; ignore the parameter if the field name does not exist in T

F'

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

T

Table sequence/entity table/multizone entity table

Return value:

Table sequence

Example:

 

A

 

1

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

 

2

=A1.rename(EID:ID)

 

3

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

 

4

=A3.open()

Open a composite table.

5

=A4.rename(EID:EID2)

Rename EID field EID2.

6

=A5.cursor().fetch()

7

=A1.rename(SURNAME:Sname,NAME1:name)

Ignore field name NAME1 because it does not exist in A1.

cs.rename()

Description:

Rename a field of a cursor.

Syntax:

cs.rename(F:F',…)

Note:

The function renames F field in cursor cs F'.

Parameter:

F

Field name

F'

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

cs

A cursor

Return value:

Cursor

Example:

 

A

 

1

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

Return a cursor.

2

=A1.rename(EID,NAME,GENDER)

Following is content of the table whose fields are renamed:

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

3

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

 

Rename EID field ID, GENDER field SEX, and return result as follows: