DSNTESA
The SQL statements in DSNTESA are run dynamically by SPUFI. DSNTESA is used in Phase 3 of the verification process.
The first group of statements in DSNTESA create a temporary work file table space and defines a created temporary table. The INSERT statements fill the table with names, midterm scores, and final examination results, and the SELECT statement then does a check of the averages. The UPDATE statements assign a grade according to the formula in the first UPDATE statement: 60% for the final and 40% for the midterm. The next SELECT statement produces the entire table. The ROLLBACK statement removes the table space and the table within it.
The following statements make some administrative queries on the system tables:
- The following SELECT statements find all the plans and packages
that are owned by the current user, and the date they were bound.
SELECT NAME, BINDDATE FROM SYSIBM.SYSPLAN WHERE CREATOR = USER;
SELECT COLLID, NAME, VERSION, BINDTIME FROM SYSIBM.SYSPACKAGE WHERE OWNER = USER;
- The following SELECT statements find the plans and packages that
require a bind or rebind before they can be run, and the plans and
packages that are automatically rebound the next time they are run.
SELECT NAME, CREATOR, BINDDATE, VALID, OPERATIVE FROM SYSIBM.SYSPLAN WHERE OPERATIVE = 'N' OR VALID = 'N';
SELECT COLLID, NAME, VERSION, BINDTIME, VALID FROM SYSIBM.SYSPACKAGE WHERE OPERATIVE = 'N' OR VALID = 'N';
- The following SELECT statements find all objects required for
the current user's programs.
SELECT DNAME, BTYPE, BCREATOR, BNAME FROM SYSIBM.SYSPLANDEP WHERE BCREATOR = USER ORDER BY DNAME, BTYPE, BCREATOR, BNAME;
SELECT DCOLLID, DNAME, BTYPE, BQUALIFIER, BNAME FROM SYSIBM.SYSPACKDEP WHERE BQUALIFIER = USER ORDER BY DCOLLID, DNAME, BTYPE, BQUALIFIER, BNAME;
- The second SELECT from SYSTABLES provides information about all
the DEPT tables regardless of the owner.
SELECT * FROM SYSIBM.SYSTABLES WHERE NAME = 'DEPT';
- The SELECT from SYSCOLUMNS supplies a description of the fields
of the DSN8D10.DEPT
table. This information can also be provided by DCLGEN, and, within
a program, the DESCRIBE statement gives this same information.
SELECT NAME, COLTYPE, LENGTH, SCALE, NULLS, REMARKS, COLNO FROM SYSIBM.SYSCOLUMNS WHERE TBNAME= 'DEPT' AND TBCREATOR = 'DSN8610' ORDER BY COLNO;
- The following SELECT statements find the kinds of authority a
user can have. Determining which tables a specific user can access
is relatively complicated because of the various authorities. If the
user has SYSADM authority, any table can be accessed.
SELECT * FROM SYSIBM.SYSPLANAUTH WHERE GRANTEE = USER; SELECT * FROM SYSIBM.SYSPACKAUTH WHERE GRANTEE = USER; SELECT * FROM SYSIBM.SYSUSERAUTH WHERE GRANTEE = USER; SELECT * FROM SYSIBM.SYSDBAUTH WHERE GRANTEE = USER; SELECT * FROM SYSIBM.SYSTABAUTH WHERE GRANTEE = USER; SELECT * FROM SYSIBM.SYSCOLAUTH WHERE GRANTEE = USER; SELECT * FROM SYSIBM.SYSRESAUTH WHERE GRANTEE = USER;
- The final four SELECT statements show the tables and views that
can be accessed directly by the current user, those that can be accessed
using a plan, and those that are accessed using the database authority.
SELECT TCREATOR, TTNAME, STNAME, GRANTOR FROM SYSIBM.SYSTABAUTH WHERE GRANTEE = USER; SELECT BNAME, BTYPE, GRANTOR, NAME FROM SYSIBM.SYSPLANAUTH, SYSIBM.SYSPLANDEP WHERE GRANTEE = USER AND NAME = DNAME AND EXECUTEAUTH ¬= ' ' AND (BTYPE = 'T' OR BTYPE = 'V'); SELECT DCOLLID, BNAME, BTYPE, BQUALIFIER, BNAME FROM SYSIBM.SYSPACKAUTH, SYSIBM.SYSPACKDEP WHERE GRANTEE = USER AND COLLID = DCOLLID AND NAME = DNAME AND EXECUTEAUTH ¬= ' ' AND (BTYPE = 'T' OR BTYPE = 'V'); SELECT NAME, CREATOR, TYPE, DBNAME, TSNAME FROM SYSIBM.SYSTABLES WHERE DBNAME IN (SELECT NAME FROM SYSIBM.SYSDBAUTH WHERE GRANTEE = USER AND DBADMAUTH ¬= ' ');