Previous Topic: Getting the Exact Column Names for an SQL TableNext Topic: Retrieving Floating Point Data from SQL Columns


Using the AS Clause to Rename SQL Columns

Long SQL column names can present a problem to CA Culprit, since you can create a null indicator name by appending _NULL_IND to the end of the previously generated REC card name. You can avoid potential errors by using an AS clause to assign an alias to each SQL column.

AS Clause Example

 col. 2
 ▼
 INPUT  DB(Q)    DICTIONARY=TSTDICT    SCHEMA=INV
 SQL SELECT "EMP-ID-0415"            AS  "ID",
*           "EMP-FIRST-NAME-0415"    AS  "FNAME",
*           "EMP-LAST-NAME-0415"     AS  "LNAME"
*    FROM EMPLOYEE
*    WHERE "EMP-ID-0415" = 2000
*    ORDER BY ID;
 0151*001  ID
 0151*002  FNAME
 0151*003  LNAME

Please note that you may not use the alias names ID, FNAME, and LNAME on most clauses in the SQL statement (Aliases are allowed on the order by clause). However, the aliases will be used to generate REC parameters, and must be used on all subsequent CA Culprit statements.

Generated REC Cards

********
REC       START    SIZE    TYPE   DP        FIELD-NAME
********
 REC      0057     00015              FNAME
 REC      0072     00004     1        FNAME_NULL_IND
 REC      0049     00004     2        ID
 REC      0053     00004     1        ID_NULL_IND
 REC      0076     00020              LNAME
 REC      0096     00004     1        LNAME_NULL_IND