home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Treasures, Inc.
/
pctreasures.mdf
/
WINDOWS
/
adabas
/
f_0001
/
env
/
odbc.ins
< prev
next >
Wrap
Text File
|
1999-11-01
|
15KB
|
535 lines
SAY --- Installing system tables for ODBC ...
/
/* @(#)ODBC.ins 11.00.09 1999-06-09
/
INIT SERVERDB
/
/
/ *******************************************************
/ Systemtables of the Conversational Component ODBC 2.x
/ *******************************************************
/
/ ********************************
/ Table SYSODBCTYPES
/ ********************************
/
/
IF $RC (EXISTS TABLE SYSODBCTYPES) = 0
THEN
BEGIN
/
DROP TABLE SYSODBCTYPES
/
COMMIT WORK
/
END
/
CREATE TABLE SYSODBCTYPES
(
"TYPE_NAME" VARCHAR(18) ASCII NOT NULL,
"DATA_TYPE" SMALLINT NOT NULL,
"PRECISION" INTEGER,
"LITERAL_PREFIX" VARCHAR(3) ASCII,
"LITERAL_SUFFIX" VARCHAR(3) ASCII,
"CREATE_PARAMS" VARCHAR(128) ASCII,
"NULLABLE" SMALLINT NOT NULL,
"CASE_SENSITIVE" SMALLINT NOT NULL,
"SEARCHABLE" SMALLINT NOT NULL,
"UNSIGNED_ATTRIBUTE" SMALLINT,
"MONEY" SMALLINT NOT NULL,
"AUTO_INCREMENT" SMALLINT,
"LOCAL_TYPE_NAME" VARCHAR(18) ASCII,
"MINIMUM_SCALE" SMALLINT,
"MAXIMUM_SCALE" SMALLINT,
"REMARKS" VARCHAR(254) ASCII
)
/
GRANT SELECT ON SYSODBCTYPES TO PUBLIC
/
DATALOAD TABLE SYSODBCTYPES
"TYPE_NAME" 1-1
"DATA_TYPE" 2-2
"PRECISION" 3-3 DEFAULT NULL
"LITERAL_PREFIX" 4-4 DEFAULT NULL
"LITERAL_SUFFIX" 5-5 DEFAULT NULL
"CREATE_PARAMS" 6-6 DEFAULT NULL
"NULLABLE" 7-7
"CASE_SENSITIVE" 8-8
"SEARCHABLE" 9-9
"UNSIGNED_ATTRIBUTE" 10-10 DEFAULT NULL
"MONEY" 11-11
"AUTO_INCREMENT" 12-12 DEFAULT NULL
"LOCAL_TYPE_NAME" 13-13 DEFAULT NULL
"MINIMUM_SCALE" 14-14 DEFAULT NULL
"MAXIMUM_SCALE" 15-15 DEFAULT NULL
"REMARKS" 16-16 DEFAULT NULL
INFILE *
DEC '/ /./'
DATE 'INTERNAL'
TIME 'INTERNAL'
NULL '? '
COMPRESS SEPARATOR '|'
/
CHAR|1|254|'|'|max length|1|1|3|?|0|?|CHAR|?|?|?
DECIMAL|2|18|?|?|precision,scale|1|0|2|0|0|?|NUMERIC|0|18|?
FIXED|3|18|?|?|precision,scale|1|0|2|0|0|?|DECIMAL|0|18|?
INTEGER|4|10|?|?|?|1|0|2|0|0|?|INTEGER|?|?|?
SMALLINT|5|5|?|?|?|1|0|2|0|0|?|SMALLINT|?|?|?
FLOAT|6|15|?|?|precision|1|0|2|0|0|?|FLOAT|?|?|?
REAL|7|15|?|?|precision|1|0|2|0|0|?|REAL|?|?|?
DOUBLE PRECISION|8|16|?|?|?|1|0|2|0|0|?|DOUBLE PRECISION|?|?|?
DATE|9|10|'|'|?|1|0|2|?|0|?|DATE|?|?|?
TIME|10|8|'|'|?|1|0|2|?|0|?|TIME|?|?|?
VARCHAR|12|4000|'|'|max length|1|1|3|?|0|?|VARCHAR|?|?|?
LONG|-1|2147483647|'|'|?|1|1|3|?|0|?|LONG|?|?|?
CHAR() BYTE|-2|254|0X|?|max length|1|0|2|?|0|?|BINARY|?|?|?
VARCHAR() BYTE|-3|4000|0X|?|max length|1|0|2|?|0|?|VARBINARY|?|?|?
LONG BYTE|-4|2147483647|?|?|?|1|0|2|?|0|?|LONG BYTE|?|?|?
BOOLEAN|-7|1|?|?|?|1|0|2|?|0|?|BOOLEAN|?|?|?
TIMESTAMP|11|19|'|'|?|1|0|2|?|0|?|TIMESTAMP|?|?|?
/
COMMIT WORK
/
/
/ ********************************
/ View SYSODBCINDEXSTAT
/ ********************************
/
CREATE OR REPLACE VIEW SYSODBCINDEXSTAT
AS SELECT
OWNER, TABLENAME, INDEXNAME, COLUMNNAME, ROWS, PAGECOUNT
FROM SYSDD.ODBC_INDEXSTATS
INTERNAL
/
GRANT SELECT ON SYSODBCINDEXSTAT TO PUBLIC
/
/
/ ********************************
/ View SYSODBCTABLESTAT
/ ********************************
/
CREATE OR REPLACE VIEW SYSODBCTABLESTAT
AS SELECT
OWNER, TABLENAME, ROWS, PAGECOUNT
FROM SYSDD.ODBC_TABLESTATS
INTERNAL
/
GRANT SELECT ON SYSODBCTABLESTAT TO PUBLIC
/
/
/ ********************************
/ View SYSODBCINDEXES
/ ********************************
/
CREATE OR REPLACE VIEW SYSODBCINDEXES
(TABLE_QUALIFIER, TABLE_OWNER, TABLE_NAME, NON_UNIQUE,
INDEX_QUALIFIER, INDEX_NAME, TYPE, SEQ_IN_INDEX, COLUMN_NAME,
COLLATION, CARDINALITY, PAGES, FILTER_CONDITION, INDEX_TYPE)
AS SELECT
NULL, OWNER, TABLENAME, NUM(DECODE(TYPE, 'UNIQUE', 0, 1)),
DECODE(INDEXNAME, 'SYSPRIMARYKEYINDEX', ' ', DECODE(INDEXNAME, ' ', TABLENAME, NULL)),
DECODE(INDEXNAME,' ', COLUMNNAME,INDEXNAME), 3, COLUMNNO, COLUMNNAME, SUBSTR(SORT, 1, 1),
NUM(NULL), NUM(NULL), NULL, TYPE
FROM SYSDD.INDEXES
INTERNAL
/
GRANT SELECT ON SYSODBCINDEXES TO PUBLIC
/
/
/
/ *******************************************************
/ Systemtables of the Conversational Component ODBC 3.x
/ *******************************************************
/
/
/ ********************************
/ Table SYSODBCTYPES3
/ ********************************
/
/
IF $RC (EXISTS TABLE SYSODBCTYPES3) = 0
THEN
BEGIN
/
DROP TABLE SYSODBCTYPES3
/
COMMIT WORK
/
END
/
CREATE TABLE SYSODBCTYPES3
(
"TYPE_NAME" VARCHAR(18) ASCII NOT NULL,
"DATA_TYPE" SMALLINT NOT NULL,
"COLUMN_SIZE" INTEGER,
"LITERAL_PREFIX" VARCHAR(3) ASCII,
"LITERAL_SUFFIX" VARCHAR(3) ASCII,
"CREATE_PARAMS" VARCHAR(128) ASCII,
"NULLABLE" SMALLINT NOT NULL,
"CASE_SENSITIVE" SMALLINT NOT NULL,
"SEARCHABLE" SMALLINT NOT NULL,
"UNSIGNED_ATTRIBUTE" SMALLINT,
"FIXED_PREC_SCALE" SMALLINT NOT NULL,
"AUTO_UNIQUE_VALUE" SMALLINT,
"LOCAL_TYPE_NAME" VARCHAR(18) ASCII,
"MINIMUM_SCALE" SMALLINT,
"MAXIMUM_SCALE" SMALLINT,
"SQL_DATA_TYPE" SMALLINT NOT NULL,
"SQL_DATETIME_SUB" SMALLINT,
"NUM_PREC_RADIX" INTEGER,
"INTERVAL_PRECISION" SMALLINT,
"REMARKS" VARCHAR(254) ASCII
)
/
GRANT SELECT ON SYSODBCTYPES3 TO PUBLIC
/
DATALOAD TABLE SYSODBCTYPES3
"TYPE_NAME" 1-1
"DATA_TYPE" 2-2
"COLUMN_SIZE" 3-3 DEFAULT NULL
"LITERAL_PREFIX" 4-4 DEFAULT NULL
"LITERAL_SUFFIX" 5-5 DEFAULT NULL
"CREATE_PARAMS" 6-6 DEFAULT NULL
"NULLABLE" 7-7
"CASE_SENSITIVE" 8-8
"SEARCHABLE" 9-9
"UNSIGNED_ATTRIBUTE" 10-10 DEFAULT NULL
"FIXED_PREC_SCALE" 11-11
"AUTO_UNIQUE_VALUE" 12-12 DEFAULT NULL
"LOCAL_TYPE_NAME" 13-13 DEFAULT NULL
"MINIMUM_SCALE" 14-14 DEFAULT NULL
"MAXIMUM_SCALE" 15-15 DEFAULT NULL
"SQL_DATA_TYPE" 16-16
"SQL_DATETIME_SUB" 17-17 DEFAULT NULL
"NUM_PREC_RADIX" 18-18 DEFAULT NULL
"INTERVAL_PRECISION" 19-19 DEFAULT NULL
"REMARKS" 20-20 DEFAULT NULL
INFILE *
DEC '/ /./'
DATE 'INTERNAL'
TIME 'INTERNAL'
NULL '? '
COMPRESS SEPARATOR '|'
/
CHAR|1|254|'|'|max length|1|1|3|?|0|?|CHAR|?|?|1|?|?|?|?
DECIMAL|2|18|?|?|precision,scale|1|0|2|0|0|?|NUMERIC|0|18|2|?|10|?|?
FIXED|3|18|?|?|precision,scale|1|0|2|0|0|?|DECIMAL|0|18|3|?|10|?|?
INTEGER|4|10|?|?|?|1|0|2|0|0|?|INTEGER|?|?|4|?|10|?|?
SMALLINT|5|5|?|?|?|1|0|2|0|0|?|SMALLINT|?|?|5|?|10|?|?
FLOAT|6|15|?|?|precision|1|0|2|0|0|?|FLOAT|?|?|6|?|10|?|?
REAL|7|15|?|?|precision|1|0|2|0|0|?|REAL|?|?|7|?|10|?|?
DOUBLE PRECISION|8|16|?|?|?|1|0|2|0|0|?|DOUBLE PRECISION|?|?|8|?|10|?|?
DATE|9|10|'|'|?|1|0|2|?|0|?|DATE|?|?|9|1|10|?|?
TIME|10|8|'|'|?|1|0|2|?|0|?|TIME|?|?|9|2|10|?|?
TIMESTAMP|11|19|'|'|?|1|0|2|?|0|?|TIMESTAMP|?|?|9|3|10|?|?
VARCHAR|12|4000|'|'|max length|1|1|3|?|0|?|VARCHAR|?|?|12|?|?|?|?
LONG|-1|2147483647|'|'|?|1|1|3|?|0|?|LONG|?|?|-1|?|?|?|?
CHAR() BYTE|-2|254|0X|?|max length|1|0|2|?|0|?|BINARY|?|?|-2|?|?|?|?
VARCHAR() BYTE|-3|4000|0X|?|max length|1|0|2|?|0|?|VARBINARY|?|?|-3|?|?|?|?
LONG BYTE|-4|2147483647|?|?|?|1|0|2|?|0|?|LONG BYTE|?|?|-4|?|?|?|?
BOOLEAN|-7|1|?|?|?|1|0|2|?|0|?|BOOLEAN|?|?|-7|?|?|?|?
/
COMMIT WORK
/
/
/ ********************************
/ View SYSODBTABLES3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCTABLES3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCTABLES3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCTABLES3
(TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TABLE_TYPE, REMARKS)
AS SELECT
NULL, OWNER, TABLENAME, DECODE(TYPE,'SYSTEM',
'SYSTEM TABLE',TYPE), NULL
FROM "SYSDD".TABLES
INTERNAL
/
GRANT SELECT ON SYSODBCTABLES3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCCOLUMNS3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCCOLUMNS3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCCOLUMNS3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCCOLUMNS3
(TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME,
DATA_TYPE, TYPE_NAME, COLUMN_SIZE, BUFFER_LENGTH, DECIMAL_DIGITS,
NUM_PREC_RADIX, NULLABLE, REMARKS, COLUMN_DEF, SQL_DATA_TYPE,
SQL_DATETIME_SUB, CHAR_OCTET_LENGTH, ORDINAL_POSITION, IS_NULLABLE,
POS, CODETYPE, KEY_SEQ)
AS SELECT
NULL, OWNER, TABLENAME, COLUMNNAME, NUM(99), DATATYPE, PRECISION,
LEN, DEC, RADIX, NULLABLE, NULL, NULL, NUM(99), NULL, LEN,
COLUMNNO, ASCII(DECODE(NULLABLE,1,'YES',2,'NO','NO')),
COLUMNNO, CODE, KEY_SEQ
FROM SYSDD.ODBC_COLUMNS
INTERNAL
/
GRANT SELECT ON SYSODBCCOLUMNS3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCINDEXSTAT3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCINDEXSTAT3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCINDEXSTAT3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCINDEXSTAT3
AS SELECT
OWNER, TABLENAME, INDEXNAME, COLUMNNAME, ROWS, PAGECOUNT
FROM SYSDD.ODBC_INDEXSTATS
INTERNAL
/
GRANT SELECT ON SYSODBCINDEXSTAT3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCTABLESTAT3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCTABLESTAT3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCTABLESTAT3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCTABLESTAT3
AS SELECT
OWNER, TABLENAME, ROWS, PAGECOUNT
FROM SYSDD.ODBC_TABLESTATS
INTERNAL
/
GRANT SELECT ON SYSODBCTABLESTAT3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCINDEXES3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCINDEXES3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCINDEXES3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCINDEXES3
(TABLE_CAT, TABLE_SCHEM, TABLE_NAME, NON_UNIQUE,
INDEX_QUALIFIER, INDEX_NAME, TYPE, ORDINAL_POSITION, COLUMN_NAME,
ASC_OR_DESC, CARDINALITY, PAGES, FILTER_CONDITION, INDEX_TYPE)
AS SELECT
NULL, OWNER, TABLENAME, NUM(DECODE(TYPE, 'UNIQUE', 0, 1)),
DECODE(INDEXNAME, ' ', TABLENAME, NULL), DECODE(INDEXNAME,' ',
COLUMNNAME,INDEXNAME), 3, COLUMNNO, COLUMNNAME, SUBSTR(SORT, 1, 1),
NUM(NULL), NUM(NULL), NULL, TYPE
FROM SYSDD.INDEXES
INTERNAL
/
GRANT SELECT ON SYSODBCINDEXES3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCFOREIGNKEY3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCFOREIGNKEY3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCFOREIGNKEY3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCFOREIGNKEY3
(PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, PKCOLUMN_NAME,
FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FKCOLUMN_NAME,
KEY_SEQ, UPDATE_RULE, DELETE_RULE, FK_NAME, PK_NAME,
DEFERRABILITY)
AS SELECT
NULL, REFOWNER, REFTABLENAME, REFCOLUMNNAME, NULL, OWNER,
TABLENAME, COLUMNNAME, KEYCOLUMNNO, NULL, NUM(DECODE(RULE,
'DELETE CASCADE',0,'DELETE RESTRICT',1,'DELETE SET NULL',2,2)),
REFNAME, NULL, NULL
FROM SYSDD.FOREIGN_KEYS
INTERNAL
/
GRANT SELECT ON SYSODBCFOREIGNKEY3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCTABLEPRIV3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCTABLEPRIV3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCTABLEPRIV3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCTABLEPRIV3
(TABLE_CAT, TABLE_SCHEM, TABLE_NAME, GRANTOR, GRANTEE,
PRIVILEGE, IS_GRANTABLE)
AS SELECT
NULL, OWNER, NAME1, GRANTOR, GRANTEE, DECODE(SUBSTR(PRIVILEGES,
LENGTH(PRIVILEGES),1),'+',SUBSTR(PRIVILEGES,1,LENGTH(PRIVILEGES)-1),
PRIVILEGES), DECODE(SUBSTR(PRIVILEGES,LENGTH(PRIVILEGES),1),'+',
'YES','NO')
FROM SYSDD.NEW_PRIVILEGES
WHERE
NAME2 IS NULL AND TYPE NOT IN ('SEQUENCE', 'DBPROC')
INTERNAL
/
GRANT SELECT ON SYSODBCTABLEPRIV3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCCOLUMNPRIV3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCCOLUMNPRIV3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCCOLUMNPRIV3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCCOLUMNPRIV3
(TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, GRANTOR,
GRANTEE, PRIVILEGE, IS_GRANTABLE)
AS SELECT
NULL, C.OWNER, C.TABLENAME, C.COLUMNNAME, P.GRANTOR, P.GRANTEE,
ASCII (DECODE (SUBSTR(P.PRIVILEGES, LENGTH(P.PRIVILEGES), 1), '+',
SUBSTR (P.PRIVILEGES, 1, LENGTH(P.PRIVILEGES) - 1), P.PRIVILEGES)),
ASCII (DECODE (SUBSTR(P.PRIVILEGES, LENGTH(P.PRIVILEGES), 1), '+',
'YES', 'NO'))
FROM SYSDD.NEW_PRIVILEGES P, SYSDD.COLUMNS C
WHERE
P.TYPE NOT IN ('SEQUENCE', 'DBPROC') AND
C.OWNER = P.OWNER AND C.TABLENAME = P.NAME1 AND
(C.COLUMNNAME = P.NAME2 OR P.NAME2 IS NULL)
INTERNAL
/
GRANT SELECT ON SYSODBCCOLUMNPRIV3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCPROCEDURE3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCPROCEDURE3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCPROCEDURE3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCPROCEDURE3
(PROCEDURE_CAT, PROCEDURE_SCHEM, PROCEDURE_NAME,
NUM_INPUT_PARAMS, NUM_OUTPUT_PARAMS, NUM_RESULT_SETS, REMARKS,
PROCEDURE_TYPE)
AS SELECT
NULL, OWNER, DBPROCEDURE, NULL, NULL, NULL, COMMENT, NUM(1)
FROM SYSDD.DBPROCEDURES
WHERE
DBPROCEDURE <> ' '
INTERNAL
/
GRANT SELECT ON SYSODBCPROCEDURE3 TO PUBLIC
/
/
/ ********************************
/ View SYSODBCPROCCOLUMN3
/ ********************************
/
IF $RC (EXISTS TABLE SYSODBCPROCCOLUMN3) = 0
THEN
BEGIN
/
DROP VIEW SYSODBCPROCCOLUMN3
/
COMMIT WORK
/
END
/
/
CREATE VIEW SYSODBCPROCCOLUMN3
(PROCEDURE_CAT, PROCEDURE_SCHEM, PROCEDURE_NAME, COLUMN_NAME,
COLUMN_TYPE, DATA_TYPE, TYPE_NAME, COLUMN_SIZE, BUFFER_LENGTH,
DECIMAL_DIGITS, NUM_PREC_RADIX, NULLABLE, REMARKS, COLUMN_DEF,
SQL_DATA_TYPE, SQL_DATETIME_SUB, CHAR_OCTET_LENGTH,
ORDINAL_POSITION, IS_NULLABLE, CODETYPE)
AS SELECT
NULL, OWNER, DBPROCEDURE, PARAMETERNAME, NUM(DECODE("IN/OUT-TYPE",
'IN',1,'IN/OUT',2,' OUT',4,0)), NUM(99), DATATYPE, LEN,
NUM(DECODE(DATATYPE,'FIXED',LEN+2,'FLOAT',DECODE((LEN DIV 8+1)*
4,4,4,8,8,12,8),'INTEGER',4,'SMALLINT',2,LEN)), DEC, DECODE(
DATATYPE,'FIXED',10,'FLOAT',10,'INTEGER',10,'SMALLINT',10,NULL),
NUM(1), NULL, NULL, NUM(99), NULL, LEN, PARAM_NO, ASCII('YES'), CODE
FROM SYSDD.DBPROCPARAMETERS
WHERE
DBPROCEDURE <> ' '
INTERNAL
/
GRANT SELECT ON SYSODBCPROCCOLUMN3 TO PUBLIC
/
/
END INIT SERVERDB
/