home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IBM Presents OS/2 Software Hits 1995
/
OS-2_SW_HITS_2ND_EDITION_1995.ISO
/
i17
/
ur423843.dsk
/
CSD3.DFI
/
RUINST.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-04-19
|
5KB
|
144 lines
/****************************************************************/
/* RUINST.CMD - Builds the database tables for the RU utility */
/****************************************************************/
trace on
database = "lm11"
If Rxfuncquery('SQLEXEC') <> 0 then
rcy = Rxfuncadd('SQLEXEC', 'SQLAR', 'SQLEXEC')
If Rxfuncquery('SQLDBS') <> 0 then
rcy = Rxfuncadd('SQLDBS', 'SQLAR', 'SQLDBS')
say 'Starting Database Manager.......'
call SQLDBS 'START DATABASE MANAGER'
/* Test to see if DBM was started or already started */
if sqlca.sqlcode <> 0 then do
if sqlca.sqlcode <> -1026 then do
say 'Could not start DATABASE MANAGER'
say 'SQLCODE = ' sqlca.sqlcode
return '1'
end
end
call SQLDBS 'START USING DATABASE 'database
if sqlca.sqlcode <> 0 then do
call DBERROR "START USING database"
return '1'
end
call CREATE_TABLES
call SQLDBS 'STOP USING DATABASE'
return
CREATE_TABLES:
/****************************************************/
/* This procedure creates the RU tables, tests */
/* if create was successful and calls an error */
/* procedure if an unexpected error occurrs */
/****************************************************/
/*****************************************************/
/* Create Ring_performance table */
/*****************************************************/
RUTable = 'CREATE TABLE LANM.RING_PERFORMANCE ',
'(segment_number char(3) NOT NULL,',
' time_logged time NOT NULL,',
' date_logged date NOT NULL,',
' interval_seconds int NOT NULL,',
' seconds_timestamp int NOT NULL,',
' utilization dec(3,1) NOT NULL)'
say 'Creating RING_PERFORMANCE table....'
call SQLEXEC 'EXECUTE IMMEDIATE :RUTable'
if sqlca.sqlcode <> 0 & sqlca.sqlcode <> -601 then
call DBERROR "Creating RING_PERFORMANCE table"
say 'Creating RINGPERF index....'
RUIndex = 'CREATE UNIQUE INDEX LANM.RINGPERF ON LANM.RING_PERFORMANCE ',
' (segment_number, seconds_timestamp)'
call SQLEXEC 'EXECUTE IMMEDIATE :RUIndex'
if sqlca.sqlcode <> 0 & sqlca.sqlcode <> 605 then
if sqlca.sqlcode <>-1024 then
call DBERROR "Creating RINGPERF index"
else
call RU_EXIT
RUComment = 'COMMENT ON TABLE LANM.RING_PERFORMANCE IS ''Ring Performance'''
call SQLEXEC 'EXECUTE IMMEDIATE :RUComment'
/* Test to see if table was created */
if sqlca.sqlcode <> 0 & sqlca.sqlcode <> -601 then
if sqlca.sqlcode <>-1024 then
call DBERROR "Creating comment on table"
else
call RU_EXIT
call SQLEXEC 'COMMIT'
/******************************************************/
/* Create RUPOLL Definitions table */
/******************************************************/
RUTable = 'CREATE TABLE LANM.RUPOLL_DEFS ',
'(segment_no char(3) NOT NULL,',
' interval char(4) NOT NULL)'
say 'Creating RUPOLL_DEFS table....'
call SQLEXEC 'EXECUTE IMMEDIATE :RUTable'
if sqlca.sqlcode <> 0 & sqlca.sqlcode <> -601 then
if sqlca.sqlcode <>-1024 then
call DBERROR "Creating RUPOLL_DEFS table"
else
call RU_EXIT
say 'Creating RUDEFS index....'
RUIndex = 'CREATE UNIQUE INDEX LANM.RUDEFS ON LANM.RUPOLL_DEFS ',
' (segment_no)'
call SQLEXEC 'EXECUTE IMMEDIATE :RUIndex'
if sqlca.sqlcode <> 0 & sqlca.sqlcode <> 605 then
if sqlca.sqlcode <>-1024 then
call DBERROR "Creating RUDEFS index"
else
call RU_EXIT
RUComment = 'COMMENT ON TABLE LANM.RUPOLL_DEFS IS ''Ring Performance Definitions'''
call SQLEXEC 'EXECUTE IMMEDIATE :RUComment'
/* Test to see if table was created */
if sqlca.sqlcode <> 0 & sqlca.sqlcode <> -601 then
if sqlca.sqlcode <>-1024 then
call DBERROR "Creating comment on table"
else
call RU_EXIT
call SQLEXEC 'COMMIT'
say 'Done.'
call RU_EXIT
RU_EXIT:
return;
DBERROR:
/*****************************************************/
/* This procedure is called if an unexpected error */
/* occurrs while creating a table. It displays the */
/* SQLCODE and SQLERRM */
/*****************************************************/
event = arg(1)
say 'Error occurred while' event
say 'SQLCODE = ' sqlca.sqlcode
say 'SQLERRM = ' sqlca.sqlerrmc
say 'Consult the Database Manager Programming Guide'
call SQLDBS 'STOP USING DATABASE'
return '1'