Last Update: 14 March 2012
Product: StarSQL
Version: 5.x
Article ID: SQV00SQ022
The simpliest way to create a restricted view is to use Classic StarAdmin (a custom install option included with StarSQL 6.0 and earlier). This document explains the requirements and steps necessary to create restricted views manually on DB2 for z/OS. Example SQL statements used to create restricted views are provided. The GRANT SQL is also provided.
Querying the SYSIBM.SYSTABLES will generate a list of all tables and views for all authorization ids. The SQLTables ODBC function is defined in such a way that the application can decide if it wants to "filter" the list based on e.g. authorization id. StarSQL always shows all available tables (when using SYSIBM) and reports in SQLGetInfo that all tables may not be accessible by the user.
To scale down the number of tables brought down, the system administrator needs to create restricted views. For example: creating a restricted view based on CURRENT SQLID, will allow user ABCD to only see tables ABCD.XXXX. Restricted views can be created based on information in SYSTABAUTH and/or SYSUSERAUTH catalog tables.
StarSQL requires that views be created for the following tables:
Example 1 shows a sample SQL statement that was used to create a restricted view of SYSTABLES. You must create a restricted view for each table that is required by StarSQL (see 'Required Tables').
SET CURRENT SQLID = 'SYSDBA';
COMMIT;
CREATE VIEW SYSDBA.SYSTABLES AS SELECT * FROM SYSIBM.SYSTABLES
WHERE (CREATOR = 'USER')
OR (CREATOR = 'USER2')
OR (CREATOR = 'USER3');
COMMIT;
Some applications require index information in order to perform updates on tables. If your application has this requirement you can restrict users to READ-ONLY access by creating a restricted view of the SYSIBM.SYSTABLES catalog table. However, all remaining tables in the list(s) above (see 'Required Tables') MUST exist under the selected AUTHID. This can be accomplished by creating empty tables based on the structure of the associated SYSIBM catalog tables. For example, execute the following SQL:
CREATE TABLE SYSDBA.SYSCOLUMNS LIKE SYSIBM.SYSCOLUMNS
CREATE TABLE SYSDBA.SYSKEYS LIKE SYSIBM.SYSKEYS
CREATE TABLE SYSDBA.SYSINDEXES LIKE SYSIBM.SYSINDEXES
CREATE TABLE SYSDBA.SYSRELS LIKE SYSIBM.SYSRELS
CREATE TABLE SYSDBA.SYSFORIEGNKEYS LIKE SYSIBM.SYSFORIEGNKEYS
CREATE TABLE SYSDBA.SYSPROCEDURES LIKE SYSIBM.SYSPROCEDURES
Note: IN DATABASE <DATABASE_NAME> must be appended to each SQL statement if it has not been entered in the StarSQL data source Advanced Options Screen.
After creating the restricted view(s), enter the AUTHID that you used in the "CREATE VIEW" statement (SYSDBA in the example above) as the SQL Catalog Qualifier in the StarSQL data source setup screen.
GRANT COMMANDS
Prior to StarSQL package binding, execute the following commands:
GRANT BINDADD TO <AUTHID>
GRANT CREATE IN COLLECTION <COLLID> TO <AUTHID>
Then proceed to bind the new packages. After the StarSQL packages are bound on the HOST, BINDADD authority can be revoked.
Then you need to grant other authids permissions to use the packages with this command:
GRANT EXECUTE on each StarSQL package (usually SWRC0000 & SYSIBM), such as
GRANT EXECUTE ON PACKAGE STARCOLL.SWRC0000 TO PUBLIC)
The information in technical documents comes without any warranty or applicability for a specific purpose. The author(s) or distributor(s) will not accept responsibility for any damage incurred directly or indirectly through use of the information contained in these documents. The instructions may need to be modified to be appropriate for the hardware and software that has been installed and configured within a particular organization. The information in technical documents should be considered only as an example and may include information from various sources, including IBM, Microsoft, and other organizations.