Previous Topic: Example 2.Next Topic: Description


SET CURRENT SQLID

This SQL statement can be executed in the following ways:

Through the CA Datacom Datadictionary Interactive SQL Service Facility (interactive)

In an application program prepared using a CA Datacom/DB SQL Preprocessor (embedded)

By using CA Dataquery (SQL & Batch Modes)

SET CURRENT SQLID

 

YES

 

Note: YES indicates a valid execution method for this statement.

The SET CURRENT SQLID statement can be prepared and executed dynamically. SET CURRENT SQLID allows the CURRENT SQLID special register to be changed to any authorization ID. The value of the CURRENT SQLID special register is the current SQL authorization ID (in this case actually a schema ID). Using SET CURRENT SQLID to change the CURRENT SQLID therefore allows you to qualify any unqualified table or view names in dynamically executed SQL statements. After you have changed the CURRENT SQLID special register with SET CURRENT SQLID, the value you specified remains in effect until either another SET CURRENT SQLID statement is executed or your application process terminates.

Note: In a Single User environment, the CURRENT SQLID affects all plans executing under an application process.

There is no authorization checking required to execute the SET CURRENT SQLID statement. The name checked for privileges when a CREATE, GRANT or REVOKE statement is dynamically prepared is the value of the accessor ID special register, not the value of CURRENT SQLID. The accessor ID becomes the owner of tables, views and indexes created by dynamic SQL statements. The value of the accessor ID special register may not be changed.

The CURRENT SQLID special register is initially set to the same value as the USER special register, which is the authorization ID of the plan that is executing. This initial value is also known as the primary SQL authorization ID. The USER register retains the original value even when the CURRENT SQLID is changed.

Note: In interactive SQL products such as CA Dataquery or CA Datacom Server, plans are generated internally, but there is always a way of specifying what authorization ID the generated plans have.

If Dynamic Plan Selection is used, the AUTHID provided in the User Requirements Table (URT) parmameter or CA Datacom CICS Services table is used to specify the authorization ID of the plan, which corresponds to the USER special register. That authorization ID is used to qualify any unqualified table or view names in the non-dynamically prepared statements in the plan. Do not confuse this with the CURRENT SQLID, which only affects dynamically prepared statements.

Following is the syntax diagram for the SET CURRENT SQLID statement:

►►─ SET CURRENT SQLID= ─┬──────────────────┬──────────────────────────────────►◄
                        ├─ USER ───────────┤
                        ├─ string-literal ─┤
                        └─ host-variable ──┘