Previous Topic: Name ConventionsNext Topic: Qualified Column Names


Qualified Table and View Names

You can qualify the names of SQL objects with authorization IDs of up to eight characters. For example, you can qualify the table PAYROLL with the authorization ID HOU:

HOU.PAYROLL

The dataviews corresponding to SQL objects must have authorization IDs. You can use the dataview authorization ID to qualify the object name in the SQL presented to the database or you can code an authorization ID explicitly in the embedded SQL. In each program resource table that includes a dataview for an SQL object, you must perform the following tasks:

You have several options for qualifying an object name based on how its dataview is defined:

Example

Consider the following program resource table definition:

Dataview              Auth‑id   Q?

EMPLOYEE              SBL       Y
PAYROLL               HOU       N

Example

Consider also the following embedded SQL statements:

EXEC SQL                            EXEC SQL
    SELECT                           SELECT ...
     FROM EMPLOYEE, PAYROLL            FROM SBL.EMPLOYEE, HOU.PAYROLL
END‑EXEC                            END‑EXEC
               EXEC SQL
                  INSERT INTO PAYROLL
                    (SELECT * FROM HOU.PAYROLL ...)
               END‑EXEC

Example

CA Ideal generates the following clauses:

SELECT ...                          SELECT ...
  FROM SBL.EMPLOYEE, PAYROLL          FROM SBL.EMPLOYEE, HOU.PAYROLL

           INSERT ... INTO PAYROLL
                        (SELECT * FROM HOU.PAYROLL ...)

In the first example, the database qualifies the table name PAYROLL with an authorization ID.

In the second example, both table names are qualified with the dataview authorization ID from the program resource fill‑in.

In the third example, two tables, HOU.PAYROLL and xxx.PAYROLL (where xxx is the CA Datacom/DB default authorization ID and is not HOU) are accessed using the one PAYROLL dataview specified in the program resource fill‑in.

The ASSIGN AUTHORIZATION command lets you specify an authorization ID to use for all tables or views specified as unqualified in the resource table.

For DB2: The ASSIGN AUTHORIZATION command also lets you replace the dataview authorization ID specified in the resource table with a new authorization ID or generate an unqualified table or view name. The interactions of the resource table, embedded SQL, and the ASSIGN AUTHORIZATION command are explained in the Command Reference Guide and the Administration Guide.

For CA Datacom SQL access: The ASSIGN AUTHORIZATION command lets you select an alternate access plan at runtime.