tldm-universe/Ardent/UV/BP/DEMO.SQL.B

983 lines
28 KiB
Plaintext
Raw Permalink Normal View History

2024-09-09 21:51:08 +00:00
*******************************************************************************
*
* Routines to make/remove release 8.3.3 demo files and tables
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
*******************************************************************************
*
* Maintenence log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description.........................................
* 10/14/98 23801 SAP Change copyrights.
* 04/28/97 20519 LAG Changed CMDARG to be a fully qualified username
* on Windows NT in routine Setschema.
* 10/15/96 19421 LAG Added quotes around schema and authorization names
* in call to CREATE SCHEMA for Windows NT.
* 03/13/96 17797 AGM Replace 'SH -c' with OS.EXEC
* 01/29/96 17671 LAG Fix problem with readseq and carriage returns
* 01/24/96 17671 LAG Port to Windows NT
* 04/25/95 16054 TFH Handle situation when LONGNAMES is off
* 04/24/95 16054 TFH Prevent "Press any key" situation (set lines = 99)
* 04/24/95 16054 TFH MAKE.DEMO.FILES: Compile all dictionaries at end
* 04/19/95 16054 TFH Change processing of create schema
* 04/18/95 16054 TFH Add 'hush' around open statements to avoid ugly msg
* 04/14/95 16054 TFH Change def'n and location of demo-information files
* 04/11/95 16054 TFH Initial version
*
*******************************************************************************
*
* This program handles the following commands:
*
* SETUP.DEMO.SCHEMA username
* Registers "username" as an SQL user (if not one already) and makes
* the current account into a schema called DEMO_username which is
* owned by username. This command must be run by an SQL user who
* is a DBA.
* MAKE.DEMO.TABLES
* Creates and loads the CIRCUS database tables into the current
* account, making the current user the owner of the tables. The
* account must be an SQL schema and the tables must not already
* exist in this schema. The names of these tables will all have
* a .T suffix.
* REMOVE.DEMO.TABLES
* Drops the CIRCUS database tables from the current schema. The
* user must be a registered SQL user who is the owner of the tables
* or a DBA.
* MAKE.DEMO.FILES
* Creates and loads the CIRCUS database files into the current
* account. The files must not already exist in this account. The
* names of these files will all have a .F suffix. The data contents
* of these files will be the same as the data contents of the
* corresponding .T tables.
* REMOVE.DEMO.FILES
* Deletes the CIRCUS database files from the current account.
*
* This program uses demo-information files, which come as part of uniVerse
* and get loaded into the <uvhome>/sample directory at installation time.
* The demo-information files are:
*
* DEMO.NAMES
* This is a UNIX file containing one line for each file in the CIRCUS
* database. Each line is the name of a CIRCUS file (without the .T or
* .F suffix) in uppercase letters, eg ACTS or ENGAGEMENTS. The names
* must be listed in the correct order for doing the 'loadfile's so that
* referential integrity is not violated during loading of tables.
* DEMO.MKTAB
* This is a UNIX file containing the CREATE TABLE commands (but not the
* ALTER TABLE statements) needed for the MAKE.DEMO.TABLES function.
* This file does not contain any loadfile commands. Table names should
* include the .T suffix, eg CREATE TABLE ACTS.T ...;
* DEMO.ALTAB
* This is a UNIX file containing the ALTER TABLE commands needed for
* the MAKE.DEMO.TABLES function, in the proper order; these ALTER
* TABLEs will be performed after data has been loaded into all of the
* tables. Table names should include the .T suffix.
* DEMO.RMTAB
* This is a UNIX file containing the ALTER TABLE and DROP TABLE
* commands needed for the REMOVE.DEMO.TABLES function. Table names
* should include the .T suffix, eg DROP TABLE ACTS.T;
* demo.fnam.t.u
* There is one demo.fnam.t.u file for each file in the CIRCUS database;
* "fnam" is the first three letters of the CIRCUS filename in lower
* case, eg demo.act.t.u or demo.eng.t.u. Each such file contains the
* data records which will be loaded into the corresponding table when
* MAKE.DEMO.TABLES is run, and (usually) loaded into the corresponding
* file when MAKE.DEMO.FILES is run.
* demo.fnam.f.u
* There may be a few demo.fnam.f.u files. If such a file exists for
* a particular "fnam", then this file is used, instead of
* demo.fnam.t.u, as the source of data records to be loaded into the
* corresponding file when MAKE.DEMO.FILES is run.
* demo.d_fnam.f.u
* There is one demo.d_fnam.f.u file for each file in the CIRCUS
* database. Each such file contains the records which will be loaded
* into the corresponding file's dictionary when MAKE.DEMO.FILES is run.
* These files are not used by MAKE.DEMO.TABLES.
*
*****************************************************************************
*
* For debugging purposes, you can specify an alternate directory for the
* demo-information files (to be used instead of <uvhome>/sample) by typing
* the full path of the alternate directory as an argument after the command.
* [This does not apply to SETUP.DEMO.SCHEMA.]
*
* For example: MAKE.DEMO.TABLES /rd/hatch/SAMPLE
*
*****************************************************************************
$OPTIONS DEFAULT
$INCLUDE UNIVERSE.INCLUDE MACHINE.NAME
$INCLUDE UNIVERSE.INCLUDE FILENAMES.H
******************
** Windows NT port
**
DEFFUN IS.FULLPATH(FILESPEC) CALLING "*IS.FULLPATH"
DEFFUN IS.EQPATHS(FILESPEC.A, FILESPEC.B) CALLING "*IS.EQPATHS"
**
******************
ERRMSG = " Consult your system administrator."
prompt ""
MAXSLEEP = 5
COMMAND = @SENTENCE
AUTH = @AUTHORIZATION
PATH = @PATH
PATH = trim(PATH)
******************
** Windows NT port
**
IF OS.TYPE = "UNIX" THEN
if PATH[1] = "/" then PATH = PATH[1,len(PATH)-1]
END ELSE
if PATH[1] = "/" OR PATH[1] = "\" then PATH = PATH[1,len(PATH)-1]
END
**
******************
* Determine what CREATE.FILE syntax to use
FLAVOR = system(1001)
if FLAVOR = 2 or FLAVOR = 8 or FLAVOR = 16 then
CREATE.SYNTAX = "PICK"
end else
CREATE.SYNTAX = ""
end
* Set large value for lines-per-screen, to avoid "Press any key..."
NUMLINES = @CRTHIGH
execute "TERM ,99"
* Find out if this account is a schema; put its name (or empty) in SCH
*
gosub Getschinfo
* Interpret the command line
*
FIRST = 1
Getcmd:
if not(FIRST) then
print "Enter command (or Q to quit): ":
input COMMAND
end
CMDNAME = upcase(field(trim(COMMAND)," ",1))
CMDARG = field(trim(COMMAND)," ",2)
begin case
case CMDNAME[1,1] = "Q"
goto Exit
case CMDNAME = "SETUP.DEMO.SCHEMA"
gosub Verwrite
gosub Setschema
goto Exit
end case
******************
** Windows NT port
**
if IS.FULLPATH(CMDARG) then UV.SAMPLE = CMDARG
IF OS.TYPE = "UNIX" THEN
if CMDARG = "." then UV.SAMPLE = "/rd/hatch/SAMPLE"
END
**
******************
begin case
case CMDNAME = "MAKE.DEMO.TABLES"
TABLE = 1
MAKE = 1
case CMDNAME = "REMOVE.DEMO.TABLES"
TABLE = 1
MAKE = 0
case CMDNAME = "MAKE.DEMO.FILES"
TABLE = 0
MAKE = 1
case CMDNAME = "REMOVE.DEMO.FILES"
TABLE = 0
MAKE = 0
case 1
if FIRST then FIRST = 0 else print "Illegal command"
goto Getcmd
end case
Start:
* Verify that user has write permission on this account and its VOC
*
gosub Verwrite
* If dealing with tables, verify that this account is a schema and
* that the user is an SQL user
*
if TABLE then gosub VerSQL
* Open the DEMO.NAMES file to FVNAMES
*
FPATH = UV.SAMPLE:"/DEMO.NAMES"
OPSTAT = 0
hush on setting OLDHUSH
openseq FPATH to FVNAMES else
OPSTAT = status()
hush OLDHUSH
print "Can't open '":FPATH:"'. ":
gosub POPERR
print ERRMSG
goto Exit
end
hush OLDHUSH
* If making tables, open the DEMO.MKTAB file to FVTCL
* If removing tables, open the DEMO.RMTAB file to FVTCL
*
if TABLE then
if MAKE then
FPATH = UV.SAMPLE:"/DEMO.MKTAB"
end else
FPATH = UV.SAMPLE:"/DEMO.RMTAB"
end
OPSTAT = 0
hush on setting OLDHUSH
openseq FPATH to FVTCL else
OPSTAT = status()
hush OLDHUSH
print "Can't open '":FPATH:"'. ":
gosub POPERR
print ERRMSG
goto Exit
end
hush OLDHUSH
end
* Now loop through DEMO.NAMES
*
NOMORE = 0
PREEXIST = 0
NOTOWNER = 0
FIRST = 1
loop
readseq FILNAM from FVNAMES else NOMORE = 1
until NOMORE do
******************
** Windows NT port
**
if OS.TYPE NE "UNIX" then
if len(FILNAM) and FILNAM[1] = char(13) then
FILNAM = FILNAM[1, len(FILNAM) - 1]
end
end
**
******************
if TABLE then FILNAMX = FILNAM:".T" else FILNAMX = FILNAM:".F"
OPSTAT = 0
hush on setting OLDHUSH
OPEN "", FILNAMX TO FVLOCAL ELSE OPSTAT = status()
hush OLDHUSH
if OPSTAT = 0 then close FVLOCAL
begin case
* If making files/tables, verify they aren't here already.
case (MAKE and OPSTAT <> -1)
if TABLE then print "A table ": else print "A file ":
print "named ":FILNAMX:" already exists."
PREEXIST = 1
* If removing tables, verify user is a DBA or tables' owner
case (not(MAKE) and TABLE and (OPSTAT = 0 or OPSTAT = -12))
if not(ISDBA) then
VALCNT = 0
loop
VALCNT += 1
VALSCH = USERREC<4,VALCNT>
VALTAB = USERREC<5,VALCNT>
until (VALSCH = "" or (VALSCH = SCH and VALTAB = FILNAMX)) do
repeat
if not(VALSCH = SCH and VALTAB = FILNAMX) then
print "You don't own table ":FILNAMX:" and are not a DBA."
NOTOWNER = 1
end
end
* If removing files, delete file now
case (not(MAKE) and not(TABLE) and OPSTAT <> -1)
if FIRST then FIRST = 0 else print ""
execute "DELETE.FILE ":FILNAMX
end case
repeat
close FVNAMES
* If making files/tables and some pre-exist (they have been listed), quit
*
if PREEXIST then
print ""
print "Can't make demo ":
if TABLE then print "tables." else print "files."
print ""
goto Exit
end
* If removing tables and user is not owner or DBA, quit
*
if NOTOWNER then
print ""
print "Can't remove demo tables."
print ""
goto Exit
end
******* I don't know why this code was here, so I'm commenting it out *******
* Update the user's VOC if making new files or tables
*
*if MAKE then EXECUTE "UPDATE.ACCOUNT"
*****************************************************************************
* Now call appropriate subroutines to make/load files, make/load tables,
* or remove tables. (If removing files, this has already been done.)
*
begin case
case (MAKE and TABLE)
SKIPFLAG = 1 ; gosub RunTCL
gosub Loadtables
gosub Runalter
case (MAKE and not(TABLE))
gosub Makefiles
case (not(MAKE) and TABLE)
SKIPFLAG = 0 ; gosub RunTCL
end case
* Print final message
*
print ""
if not(MAKE) then
print "All demo ":
if TABLE then print "tables": else print "files":
print " removed."
print ""
goto Exit
end
print "All demo ":
if TABLE then print "tables": else print "files":
print " initialized."
print ""
goto Exit
* Restore page-length and stop
*
Exit:
execute "TERM ,":NUMLINES
STOP
******************************************************************************
* S U B R O U T I N E S
******************************************************************************
Getschinfo:
* This subroutine determines whether the current account is a schema, and
* if so it returns the schema name. This routine doesn't use @SCHEMA
* because, unfortunately, @SCHEMA doesn't get updated until a user logs
* out of uniVerse and back in again, so @SCHEMA isn't always reliable.
* inputs are PATH is the full pathname of the account
* outputs are SCH = schema name if this is a schema, else empty string
*
* Open UV_SCHEMA
hush on setting OLDHUSH
open "UV_SCHEMA" to FVAR else
hush OLDHUSH
OPSTAT = status()
print "Can't open UV_SCHEMA. ":
gosub POPERR
print ERRMSG
goto Exit
end
hush OLDHUSH
* Lock UV_SCHEMA
LSLEEP = MAXSLEEP
Getsin1:
if LSLEEP <=0 then
close FVAR
print "Can't lock UV_SCHEMA."
goto Exit
end
filelock FVAR locked
LSLEEP -= 1
sleep 2
goto Getsin1
end
* Search UV_SCHEMA for path of this account
select FVAR
SCH = ""
FOUND = 0
NOMORE = 0
loop
until (FOUND or NOMORE) do
readnext SCH then
read SCHREC from FVAR,SCH then
******************
** Windows NT port
**
if IS.EQPATHS(trim(SCHREC<2>), PATH) then FOUND = 1
**
******************
end else
fileunlock FVAR
close FVAR
print "Can't read UV_SCHEMA."
goto Exit
end
end else NOMORE = 1
repeat
fileunlock FVAR
close FVAR
return ; * return from Getschinfo
*----------------------------------------------------------------------------
Verwrite:
* This subroutine verifies that user can write into this account
* inputs are PATH is full path of current account's directory
* AUTH is current username
* CMDNAME is the command being executed
* output If user can't write into this account, subroutine STOPs
*
* Verify that user has write permission to this account's directory
*
VERDIR:
TCH = OS.EXEC:' "':TOUCH.CMD:' dUMMy.newSQL"'
RMV = OS.EXEC:' "':RM.CMD:' dUMMy.newSQL"'
TVAR = ""
execute TCH capturing TVAR
if len(TVAR) > 1 then
print "Can't run ":CMDNAME:" because current user (":AUTH:") lacks"
print " OS write permission on this account (":PATH:")"
goto Exit
end
execute RMV capturing TVAR
* Verify that user has write permission to the VOC
VERVOC:
VPATH = PATH:"/VOC"
hush on setting OLDHUSH
openpath VPATH to FVAR else
hush OLDHUSH
print "Can't run ":CMDNAME:": Can't open '":VPATH:"'"
goto Exit
end
hush OLDHUSH
LSLEEP = MAXSLEEP
VERVOC1:
if LSLEEP <= 0 then
close FVAR
print "Can't run ":CMDNAME:": '":VPATH:"' is locked"
goto Exit
end
readu TVAR from FVAR,"VOC" locked
LSLEEP -= 1
sleep 2
goto VERVOC1
end else
close FVAR
print "Can't run ":CMDNAME:": Can't read from '":VPATH:"'"
goto Exit
end
write TVAR to FVAR,"VOC" else
close FVAR
print "Can't run ":CMDNAME:": Can't write to '":VPATH:"'"
goto Exit
end
close FVAR
return ; * return from Verwrite
*---------------------------------------------------------------------------
Setschema:
* This subroutine does the SETUP.DEMO.SCHEMA command
* inputs AUTH is current username
* CMDARG is requested username
* CMDNAME is command being executed
*
* First verify that current user is a registered SQL user who is a DBA
*
UNAME = AUTH
gosub Getuserinfo
if not(ISDBA) then
print "You can't run ":CMDNAME:" because you are not an SQL DBA."
goto Exit
end
* Then register requested user as an SQL user (if not already one)
*
if (CMDARG = "" or CMDARG = " ") then
print "You must specify a 'username' argument for ":CMDNAME:"."
goto Exit
end
******************
** Windows NT port
**
IF OS.TYPE # "UNIX" THEN
* Prefix the domain name if required.
IF FIELD(CMDARG, "\", 2) = "" THEN
CMDARG = UPCASE(FIELD(AUTH, "\", 1)):"\":CMDARG
END
END
UNAME = CMDARG
gosub Getuserinfo
******************
** Windows NT port
**
IF OS.TYPE # "UNIX" THEN
* Try an uppercase domain name and lowercase username.
if ISSQLUSER = 0 then
CMDARG = UPCASE(FIELD(CMDARG, "\", 1)):"\":DOWNCASE(FIELD(CMDARG, "\", 2))
end
UNAME = CMDARG
gosub Getuserinfo
END
if ISSQLUSER then
print "Username '":CMDARG:"' is already a registered SQL User."
end else
print "Registering '":CMDARG:"' as an SQL user."
execute "GRANT CONNECT TO ":CMDARG:";" capturing GRANTMSG
* Remove special character at end of message
GRANTMSG = GRANTMSG[1,len(GRANTMSG)-1]
loop
remove line from GRANTMSG setting delim
until delim = 0 and line = ''
print line
repeat
* If username is not in /etc/passwd, quit
findstr " aborted" in GRANTMSG setting FMC then
goto Exit
end
end
* Then make this account into an SQL schema (if it isn't one already)
*
if SCH = "" then
******************
** Windows NT port
**
IF OS.TYPE = "UNIX" THEN
execute "CREATE SCHEMA DEMO_":CMDARG:" AUTHORIZATION ":CMDARG:";"
END ELSE
CMDARG = FIELD(CMDARG, "\", 2)
execute 'CREATE SCHEMA "DEMO_':CMDARG:'" AUTHORIZATION "':CMDARG:'";'
END
**
******************
end else
print "This account is already an SQL Schema called '":SCH:"'."
end
return ; * return from Setschema
*-----------------------------------------------------------------------------
VerSQL:
* This subroutine is used when making/removing demo tables
* inputs are PATH is full path of current account's directory
* AUTH is current username
* CMDNAME is the command being executed
* SCH current schema name (or empty if not a schema)
* outputs are if user is not an SQL user, subroutine STOPs
* if this is not an SQL schema, subroutine STOPs
* USERREC contains UV_USERS record for current user
* ISDBA = 1 if current user is a DBA, else 0
*
* First verify that user is a registered SQL user (and if so, determine if
* user is a DBA)
*
VERUSER:
UNAME = AUTH
gosub Getuserinfo
if not(ISSQLUSER) then
print "You can't run ":CMDNAME:" because you are not an SQL User."
print "Ask a DBA to run SETUP.DEMO.SCHEMA for you."
goto Exit
end
* Then verify that this account is an SQL schema
*
VERACCT:
if SCH = "" then
print "You can't run ":CMDNAME:" because ":
print "this account is not an SQL Schema."
print "Ask a DBA to run SETUP.DEMO.SCHEMA for you."
goto Exit
end
return ; * return from VerSQL
*----------------------------------------------------------------------------
Getuserinfo:
* This subroutine determines whether a named user is a registered SQL user.
* If so, it determines if the user is a DBA.
* inputs are UNAME is username to be looked up
* outputs are ISSQLUSER = 1 if user is an SQL user, else 0
* ISDBA = 1 if user is a DBA, else 0
* USERREC contains UV_USERS record for user
*
* Open UV_USERS
hush on setting OLDHUSH
open "UV_USERS" to FVAR else
hush OLDHUSH
OPSTAT = status()
print "Can't open UV_USERS. ":
gosub POPERR
print ERRMSG
goto Exit
end
hush OLDHUSH
* Read UV_USERS record for this user (if present)
ISSQLUSER = 0
ISDBA = 0
read USERREC from FVAR,UNAME then
ISSQLUSER = 1
if USERREC<1> = "YES" then
ISDBA = 1
end
end
close FVAR
return ; * return from Getuserinfo
*----------------------------------------------------------------------------
RunTCL:
* This subroutine executes one set of TCL commands found in a UNIX file
* input FVTCL is the file variable opened to the command file
* SKIPFLAG = 1 means skip a line after each command, else 0
* output FVTCL is closed by this subroutine
*
NOTCL = 0
loop
readseq TCL from FVTCL else NOTCL = 1
until NOTCL do
* Remove trailing spaces or whatever
loop
until TCL[1] = ";" do
TCL = TCL[1,len(TCL)-1]
repeat
execute TCL
if SKIPFLAG then print ""
repeat
close FVTCL
return ; * from RunTCL
*----------------------------------------------------------------------------
Loadtables:
* This subroutine loads data into all demo tables (xxx.T) after they have
* been created.
* inputs are UV.SAMPLE is the directory containing the DEMO.NAMES
*
* Reopen the DEMO.NAMES file to FVNAMES
*
FPATH = UV.SAMPLE:"/DEMO.NAMES"
OPSTAT = 0
hush on setting OLDHUSH
openseq FPATH to FVNAMES else
hush OLDHUSH
OPSTAT = status()
print "Can't open '":FPATH:"'. ":
gosub POPERR
print ERRMSG
goto Exit
end
hush OLDHUSH
NOMORE = 0
loop
readseq FILNAM from FVNAMES else NOMORE = 1
until NOMORE do
******************
** Windows NT port
**
if OS.TYPE NE "UNIX" then
if len(FILNAM) and FILNAM[1] = char(13) then
FILNAM = FILNAM[1, len(FILNAM) - 1]
end
end
**
******************
FILNAMX = FILNAM:".T"
gosub Loadone
repeat
close FVNAMES
return ; * from Loadtables
*----------------------------------------------------------------------------
Makefiles:
* This subroutine creates all demo files (xxx.F) and their dictionaries
* It also loads data into all files and their dictionaries and compiles
* the dictionaries.
* inputs are UV.SAMPLE is the directory containing the DEMO.NAMES
*
* Reopen the DEMO.NAMES file to FVNAMES
*
FPATH = UV.SAMPLE:"/DEMO.NAMES"
OPSTAT = 0
hush on setting OLDHUSH
openseq FPATH to FVNAMES else
hush OLDHUSH
OPSTAT = status()
print "Can't open '":FPATH:"'. ":
gosub POPERR
print ERRMSG
goto Exit
end
hush OLDHUSH
* Create files and dictionaries, and load data into them
*
NOMORE = 0
loop
readseq FILNAM from FVNAMES else NOMORE = 1
until NOMORE do
******************
** Windows NT port
**
if OS.TYPE NE "UNIX" then
if len(FILNAM) and FILNAM[1] = char(13) then
FILNAM = FILNAM[1, len(FILNAM) - 1]
end
end
**
******************
FILNAMX = FILNAM:".F"
gosub Makeone
gosub Loadone
print ""
repeat
close FVNAMES
* Compile all dictionaries (this must be done last since there may be
* I-descriptors containing TRANS references to other files)
*
FPATH = UV.SAMPLE:"/DEMO.NAMES"
OPSTAT = 0
hush on setting OLDHUSH
openseq FPATH to FVNAMES else
hush OLDHUSH
OPSTAT = status()
print "Can't open '":FPATH:"'. ":
gosub POPERR
print ERRMSG
goto Exit
end
hush OLDHUSH
NOMORE = 0
loop
readseq FILNAM from FVNAMES else NOMORE = 1
until NOMORE do
******************
** Windows NT port
**
if OS.TYPE NE "UNIX" then
if len(FILNAM) and FILNAM[1] = char(13) then
FILNAM = FILNAM[1, len(FILNAM) - 1]
end
end
**
******************
execute "CD ":FILNAM:".F"
repeat
close FVNAMES
return ; * from Makefiles
*----------------------------------------------------------------------------
Makeone:
* This subroutine creates a file and its dictionary, then clears the dict.
* inputs FILNAMX is name of file to create (ends with .F)
*
IF CREATE.SYNTAX = "PICK" THEN
EXECUTE "CREATE.FILE DATA ":FILNAMX:" 2,2,2 Demo File"
EXECUTE "CREATE.FILE DICT ":FILNAMX:" 1,2,3 Demo File" capturing DICTOUT
END ELSE
EXECUTE "CREATE.FILE DATA ":FILNAMX:" 2 2 2 Demo File"
EXECUTE "CREATE.FILE DICT ":FILNAMX:" 3 1 2 Demo File" capturing DICTOUT
END
loop
DICTPR = remove(DICTOUT,MARK)
until MARK = 0 do
findstr " default" in DICTPR setting FMC else print DICTPR
repeat
hush on setting OLDHUSH
EXECUTE "CLEAR.FILE DICT ":FILNAMX
hush OLDHUSH
return ; * from Makeone
*----------------------------------------------------------------------------
Loadone:
* This subroutine loads data into a table, or into a file and its dictionary.
* inputs are FILNAMX is the table/file name including the .T or .F suffix
* TABLE is 1 if making tables, 0 if making files
* UV.SAMPLE is directory containing necessary .u files
*
ABRV = downcase(FILNAMX[1,3])
TABPATH = UV.SAMPLE:"/demo.":ABRV:".t.u"
TCL.CMD = OS.EXEC:" '":UV.BIN:"/loadfile"
if TABLE then
TCL = TCL.CMD:" ":TABPATH:" ":FILNAMX:"'"
execute TCL
end else
FILPATH = UV.SAMPLE:"/demo.":ABRV:".f.u"
FPATH = FILPATH ; gosub Checkone
if NOT(FEXIST) then
FILEPATH = TABPATH
end
gosub Findnames ; * find UNIX filenames for data and dictionary
TCL = TCL.CMD:" ":FILEPATH:" ":DATANAM:"'"
execute TCL
DICTPATH = UV.SAMPLE:"/demo.d_":ABRV:".f.u"
TCL = TCL.CMD:" ":DICTPATH:" ":DICTNAM:"'"
execute TCL
end
**
******************
return ; * from Loadone
*----------------------------------------------------------------------------
Runalter:
* This subroutine does any ALTER TABLE commands that may be necessary for the
* MAKE.DEMO.TABLES function (these commands are in the DEMO.ALTAB file).
* The ALTER TABLEs are done after data has been loaded into the tables.
*
* Open the DEMO.ALTAB file to FVTCL
*
FPATH = UV.SAMPLE:"/DEMO.ALTAB"
hush on setting OLDHUSH
openseq FPATH to FVTCL then
hush OLDHUSH
SKIPFLAG = 0 ; gosub RunTCL
end else
hush OLDHUSH
end
return ; * from Runalter
*----------------------------------------------------------------------------
Checkone:
* This subroutine checks if a UNIX file exists
* input FPATH is full pathname of file to be checked
* outputs FEXIST = 1 if the file exists (can be opened), else 0
* OPSTAT contains error status if file can't be opened, else 0
*
FEXIST = 0
OPSTAT = 0
hush on setting OLDHUSH
openseq FPATH to FVEX then
hush OLDHUSH
FEXIST = 1
close FVEX
end else
OPSTAT = status()
hush OLDHUSH
end
return ; * from Checkone
*----------------------------------------------------------------------------
Findnames:
* This subroutine finds the UNIX filenames for the data and dictionary parts
* of a uniVerse file, by reading its VOC entry. It is needed in case the
* account has LONGNAMES turned off.
* inputs FILNAMX is the uniVerse filename
* CMDNAME is command being executed
* outputs DATANAM is the UNIX filename of the file's data
* DICTNAM is the UNIX filename of the file's dictionary
*
VPATH = PATH:"/VOC"
hush on setting OLDHUSH
openpath VPATH to FVAR else
hush OLDHUSH
print "Aborting ":CMDNAME:": Can't open '":VPATH:"'"
goto Exit
end
hush OLDHUSH
LSLEEP = MAXSLEEP
Fnam1:
if LSLEEP <= 0 then
close FVAR
print "Aborting ":CMDNAME:": '":VPATH:"' is locked"
goto Exit
end
readu TVAR from FVAR,FILNAMX locked
LSLEEP -= 1
sleep 2
goto Fnam1
end else
close FVAR
print "Aborting ":CMDNAME:": Can't read from '":VPATH:"'"
goto Exit
end
DATANAM = TVAR<2>
DICTNAM = TVAR<3>
close FVAR
return ; * from Findnames
*----------------------------------------------------------------------------
POPERR:
* Print error message when unable to open file (partial msg is already printed)
* input = OPSTAT, which contains status()
*
begin case
case OPSTAT = -1
print "Filename not in VOC"
case OPSTAT = -2
print "Non-existent or inaccessible file"
case OPSTAT = -3
print "No OS permission"
case OPSTAT = -4
print "No OS permission or invalid file"
case OPSTAT = -5
print "OS read error"
case OPSTAT = -6
print "Can't lock file header"
case OPSTAT = -7
print "Bad file rev or byte-swap"
case OPSTAT = -8
print "Invalid part-file info"
case OPSTAT = -9
print "Invalid type 30 info"
case OPSTAT = -10
print "File marked inconsistent"
case OPSTAT = -11
print "SQL view"
case OPSTAT = -12
print "No SQL permission"
case OPSTAT = -13
print "Problem with index"
case 1
print "Status = ":OPSTAT
end case
return ; *from POPERR
*----------------------------------------------------------------------------
END