The column SQLRecord field property
specifies the name of the database table column that is associated
with the field.
The default is the name of the field. EGL uses the column name
and related field to create default SQL statements (see "SQL data
access").
The column name can be a quoted string, a character variable, or
a concatenation, as in the following example:
Record CustomerRecordPart type SQLRecord {tableNames = [["CUSTOMER"]]}
customerNumber INT {column = "Column" :: "01"};
...
end
Furthermore, the quoted string might itself be complex, as in the
following example:
record Q type SQLRecord
myField int { column = "COLUMN01 || 10 + COLUMN02 * 5" };
end
Restriction: When you code an EGL
add or
replace statement
that accesses a complex
column property
value such as the one just shown, the SQL INSERT and UPDATE statements
that are generated for you might not be valid.
If you have coded
a complex value because you want to generate an INTO clause for a
SELECT statement, consider providing your own INTO clause. For details,
see the SELECT statement restriction that is described in "get considerations
for SQL."
The value of the
column property might
include a qualifier. The qualifier might be either a table name or
a schema name followed by a table name. The following example references
the schema named MYSCHEMA and the table named CUSTOMER:
Record CustomerRecordPart type SQLRecord {tableNames = [["MYSCHEMA.CUSTOMER"]]}
customerNumber INT {column = "MYSCHEMA.CUSTOMER.Column01"};
...
end
Consider the following case: your code has a
get or
open statement
that uses an SQL record, includes explicit SQL, and lacks an INTO
clause. For example, here is EGL code that includes such a
get statement:
customer CustomerRecord{};
get customer with #sql{
select MySCHEMA.CUSTOMER.Column01
from MYSCHEMA.CUSTOMER
where MYSCHEMA.CUSTOMER.Column02 = "AZ"};
In the get or open statement
just described, the qualification used for a column name in the SQL SELECT clause
must match the qualification used for the corresponding field in the
Record part.
Also, a special syntax is necessary if a column name is one of
the following SQL reserved words:
- CALL
- FROM
- GROUP
- HAVING
- INSERT
- ORDER
- SELECT
- SET
- UNION
- UPDATE
- VALUES
- WHERE
As shown in the following example, each of those names must be
embedded in a double set of quotation marks, and each of the internal
quotation marks must be preceded by an escape character (\):
column = "\"SELECT\""
A similar situation applies if you use any of those reserved words
as a table name.