home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
asctos.zip
/
ASCTOSQL.CMD
Wrap
OS/2 REXX Batch file
|
1993-05-17
|
6KB
|
169 lines
/*******************************************************************/
/* ASCTOSQL.CMD - Converts IBM LAN NetView Start (Start) ASCII */
/* database files to data rows in a Database Manager database. */
/* */
/* This applet contains the code listed in the "Network Plotting */
/* Formation: The LAN NetView Start Objects" article in the */
/* Spring 1993 issue of the OS/2 Developer magazine. */
/* */
/* An updated version of this applet, called ASCTOSQ2.CMD, is */
/* available with the IBM LAN NetView Start 1.1 product. By */
/* examining either applet, you can see how the ASCII and SQL */
/* databases for the Start product work. */
/* */
/* (c) Copyright IBM Corp., 1993 */
/* */
/* DISCLAIMER OF WARRANTIES: */
/* The code provided in this applet program was created by the */
/* IBM Corporation. This code is provided "AS IS", without */
/* warranty or support of any kind. IBM shall not be liable for */
/* any damages arising out of the use of this applet code, even if */
/* the users have been advised of the possibility of such damages. */
/* IBM reserves the right to make improvements or changes to this */
/* applet code at any time without any notice to you. This applet */
/* can be further copied and redistributed without restriction. */
/* */
/*******************************************************************/
/* Get the source directory name and target database name. */
parse upper arg dpath dbname rest
if ((dpath = '?') | (dpath = '')) then
do
say 'ASCTOSQL.CMD - Converts IBM LAN NetView Start ASCII database'
say 'files to data rows in a Database Manager database.'
say 'An example call:'
say ' '
say 'ASCTOSQL directory-with-ASCII-files sql-dbname'
say 'ASCTOSQL E:\NET1\ NETWORK'
say ' '
say 'The SQL database must have been created by LAN NetView Start'
say 'before this program is invoked.'
exit
end
if \(substr(dpath,length(dpath),length(dpath)) = '\') then
dpath = dpath || '\'
/* Load REXX utilities and initialize variables */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
numtables = 15
tblname.1 = 'NETWORKS'
tblname.2 = 'TOPOLOGIES'
tblname.3 = 'FOLDERS'
tblname.4 = 'NODES'
tblname.5 = 'CONNECTIONS'
tblname.6 = 'ADAPTERPARMS'
tblname.7 = 'EMDFTPARMS'
tblname.8 = 'EMNONDFTPARMS'
tblname.9 = 'INCLUDES'
tblname.10 = 'HOSTPARMS'
tblname.11 = 'APPLICATIONS'
tblname.12 = 'RTRANSFORMERS'
tblname.13 = 'LCUTRANSFORMERS'
tblname.14 = 'NVTRANSFORMERS'
tblname.15 = 'LCUMAP'
setname.1 = 'NODE_NAME_SET'
setname.2 = 'LOCAL_NODE_NAME_SET'
setname.3 = 'NODE_LAN_ADDRESS_SET'
setname.4 = 'DBWORKSTATION_NAME_SET'
setname.5 = 'LSCOMPUTER_NAME_SET'
setname.6 = 'NODE_DOMAIN_NAME_SET'
/* Delete any DEL and MSG files that already exist. */
do i = 1 to numtables
len = 8
if length(tblname.i) < 8 then
len = length(tblname.i)
delfilename.i = substr(tblname.i,1,len)
'erase ' delfilename.i || '.DEL'
'erase ' delfilename.i || '.MSG'
end
/* Find the topology files. */
fullpath = dpath || '*.TOP'
call SysFileTree fullpath, 'file', 'F'
do i = 1 to file.0
filename.i = substr(file.i,38)
end
numfiles = file.0
/* There's only one network file to find. */
fullpath = dpath || '*.NET'
call SysFileTree fullpath, 'file', 'F'
numfiles = numfiles+1
filename.numfiles = substr(file.1,38)
/* Go through each of the files and store them
in the appropriate DEL file */
do i = 1 to numfiles
say 'Processing File: ' || filename.i
outfilename = 'NONE'
do until lines(filename.i) = 0
inline = linein(filename.i)
skip = false
do j = 1 to numtables
if (tblname.j = substr(inline, 2, length(inline))) then
do
outfilename = delfilename.j || '.DEL'
say ' On table: ' || tblname.j
skip = true
end
end
/* if a set name was encountered, skip it and its data rows */
do j = 1 to 5
if (setname.j = substr(inline, 2, length(inline))) then
do
outfilename = 'NONE'
skip = true
end
end
if (skip = false & outfilename <> 'NONE') then
do
/* if in the topology section and the
topology id isn't 2 or 3, skip the row */
if ((outfilename = 'TOPOLOGI.DEL') |
(outfilename = 'FOLDERS.DEL')) then
do
topid = substr(inline, 1, (pos(',',inline) -1))
tempstr = translate(filename.i, ' ', '\')
tempstr = translate(tempstr, ' ', '.')
fileid = word(tempstr, (words(tempstr)-1))
if (\(topid = fileid) | (fileid = 2) | (fileid = 3)) then
rc = lineout(outfilename, inline)
end
else
rc = lineout(outfilename, inline)
end
end
end /* do */
/* Close all the DEL files. */
do i = 1 to numtables
rc = lineout(delfilename.i || '.DEL')
end
call dbm "STARTDBM"
call dbm "START USING DATABASE " || dbname
/* Import the DEL files into the database */
do i = 1 to numtables
say 'Importing into table: ' || tblname.i
call dbm "DELETE FROM " || tblname.i
call dbm "IMPORT TO " || dbname || " FROM " || delfilename.i || ,
".DEL OF DEL REPLACE INTO " || tblname.i || " MESSAGES " || ,
delfilename.i || ".MSG"
end
call dbm "STOP USING DATABASE"
/* call dbm "STOPDBM" */
say ' '
say 'ASCII to SQL DBM conversion complete.'
say 'Examine the *.MSG message files for import warning messages,'
say ' if any. A data row might be rejected because it contained'
say ' double quotes in a string value.'