Page History
...
The secondary rule is that if an identifier does not have a '#' or ':' then it will be interpreted as a column name unless it is also an SQL Name, in which case it will be left exactly as typed in the generated code. The Visual LANSA Editor will display the following warning if this is the case:
Ambiguous. Token <name> is an SQL keyword and a LANSA field. If it's a LANSA field, prepend a '#' to the field.
Following are some examples to help explain it more fully.
...
If the file is using mangled names or Names then this code will not work:
Select_Sql Fields(#SECTION) From_Files((PSLMSTX2)) Group_By(SECTION)
Add_Entry
Endselect
The SQL would be:
SELECT "SectionCode" FROM "EVDEXLIB"."PersonnelMaster2" GROUP BY "SECTION"
...
To fix this code in the most flexible manner (See Note 2 following) prepend a '#' to the name as in:
Select_Sql Fields(#SECTION) From_Files((PSLMSTX2)) Group_By(
...
#SECTION)
Add_Entry
Endselect
The SQL for this would be:
...
But if the field name is not an SQL keyword like EMPNO here, it WILL automatically convert the Field name to the actual column name, with or without the '#':
Select_Sql Fields(#EMPNO) From_Files((PSLMSTX2)) Group_By(EMPNO)
Add_Entry
Endselect
If the Name for EMPNO is EmployeeNumber, and PSLMSTX2 allows Names (i.e. long names) then the Group_By EMPNO will be resolved to EmployeeNumber. The SQL would be:
SELECT "EmployeeNumber" FROM "EVDEXLIB"."PersonnelMaster2" GROUP BY "EmployeeNumber"
| Note |
|---|
| Note 1: '#Field' means use the column name in the generated SQL in all parameters except when it's the ONLY value in WHERE or HAVING, in which case it will generate the runtime contents of the Field. The Free Format version of SELECT_SQL - the USING parameter - is not included in this. It has its own semantics described in SELECT_SQL Free Format Parameters. |
| Note |
|---|
| Note 2: 'Flexible manner' in the sense that if the old style Windows mangling of column names is being used then the generator will automatically use 'S_CTION' for Windows & Linux and 'SECTION' on IBM i. |