Here’s how to use rename() function.
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.
Parameter:
F |
A field name |
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 T with modified field names
Example:
|
A |
|
1 |
=demo.query("select * from EMPLOYEE")
|
|
2 |
=A1.rename(EID:ID)
|
|
=file("D:\\emp1.ctx") |
|
|
4 |
=A3.open() |
Open a composite table |
5 |
=A4.rename(EID:EID2) |
Rename EID field EID2 |
6 |
=A5.cursor().fetch() |
|
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:
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) |
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:
|