#!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 2002-09-20 08:11 CDT by . # Source directory was `/home/akaser/tmp'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 21187 -rwxr--r-- Readme.txt # 84979 -rw-r--r-- infmx2html.4gl # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"' elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"' elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$2 "$8"' else shar_touch=: echo $echo 'WARNING: not restoring timestamps. Consider getting and' $echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch # if mkdir _sh05999; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= Readme.txt ============== if test -f 'Readme.txt' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'Readme.txt' '(file already exists)' else $echo 'x -' extracting 'Readme.txt' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'Readme.txt' && #################################################################### # THIS FILE WAS CREATED USING -VI- WITH 132 COLUMNS #################################################################### # PLEASE READ THE WHOLE TEXT BEFORE COMPILING OR USING # # Program: infmx2html.4gl # Author : Tony Kaser # Date : May 26 2000 # Informix Version : 7.22 # Email : akaser@totalwebcreations.com # # # This program is distributed as is and the author assumes no liability for any damages # that may result from it's use. You are free to use, modify, distribute this program # as you like provided this text is included as is. # # If you have any suggestions for enhancements or make any enhancements please email me # at the above email address. Currently I am only making enhancements as I have need/time. # Since I am distributing this as shareware I do not offer any support. I will however # try to read my email and respond if I can. # # Shortly after I released the initial version of this program I receieved requests and # comments from users. I would like to apologize for failing to respond. # # Also, in reading this text again I find I made no mention of the fact that this was based # on the program 'makedic.4gl' by Mario Estrada. Apologizes to Mario. # # The old version of this program I released over 2 years ago was written against an # Informix version 5.0 database # I am currently using infmx2html.4gl against Informix version 7.22.UC2 # # Compiling: c4gl infmx2html.4gl -o infmx2html.4ge # you should not need to link in anything special to get it to compile. # If you wish to use this against other Informix versions you may need to # make modification. # # # Syntax : infmx2html.4ge <-d database_name> <-a> <-p root_path> # OPTIONS # -d database_name : identify the database you wish to build pages for # The heirarchy is the same but will build for only # the database 'database_name' # -a : This option will tell the program to build pages for # ALL databases managed by the server. This is the # DEFAULT and does not need to be specified. # -p root_path : root_path should be a fully qualified path, or a relative # path. DEFAULT is the current directory. This is the top # of the heirarchy (see below). All directories/html pages # will be built under this directory. # NOTE # Options -d and -a are mutually exclusive and will cause the program to abort # if they are but specified. # # # # Comments: Please email comments to the address above. # Please email complaints to /dev/null # # Description: This program creates a large set of files that describe your InformixServer # and all the databases that it manages. # The first page created is a file called 'DBNames.html'. This is created in a # directory which is the name of your InformixServer. This is located under the # current/selected directory. See heirarchy below for directory structure. # # PROCEDURES/TRIGGERS # These pages will create three more frames. # * The first frame is an html table containing a list of the procedures/triggers. # * The second frame there is nothing. This is intentional as it gives a nice # margin between the first frame and the data in the third frame. # * The third frame contains the actual body of the procedure or the trigger. # According to the Informix manuals there are two pieces of interest for a trigger. # * The first is the Header definition. # * The second is the triggered actions. # Procedures/Triggers pages are written out as text files. This is because the database # contains the body in several rows in a char field. This field may contain newlines. # Html would not recognize the newlines and would make it had to read. # Ideally I should build a function to convert all newlines to '
' Tags. # Then I could set up some more linking off the page, like to the tbales. # # Since the site I am currently at does not use triggers, yet, I can not really # do too much with them. # # TABLES # The tables page creates three frames also. # * The first frame is a list of owners of tables in the database and the # number of tables they own. # Each of the owner names is a link. Pressing this link causes an index # to appear in the second frame directly below the first. # * The second frame just shows the alphabet as a set of links. This is # used to navigate the table index. Pressing a letter of the alphabet here # will cause the index of tables to be displayed in the third frame at the # begining of the list of tables that start with that letter. # * The third frame list all the tables owned by the selected owner. These tables # are listed alphabetically and in sections by alphabet. # Selecting a table will cause your browser to open another window that # will contain the table information. This allow you to view multiple tables at # the same time. # The html page that comes up to show the table information is broken up into three # Html tables # * The first table lists all the indexes for the table and what they are # comprised of and whether or not they are unique or duplicate indexes. # * The second table lists the parent tables and child tables if it can # determine them. These are determined from the syscontraints table and the # sysreferences table. If there is a better way please change it. I would # appreciate an email from anyone making changes so that I can update my version. # * The third table is optional and may not be created, this depends on whether or # not you store your Data Dictionary in the database. If the table 'tabdefs' is # found (see cursor td_curs in the PrepSqls() function) a table will be created # which will contain a description of your database. # * The third table is the actual table definition/scheme. # All datatypes on in the scheme are linked to an html page that when selected # will apear to give you some general information about that datatype. # Once again if you store your data dictionary in the database a column will be # added to the columns definitions table that will describe the column. This should # be stored in a table called 'coldefs' (see cursor cd_curs in the PrepSqls() function) # # This is an incomplete project. # Still To Do List: # 1: Build a set of pages showing # a. Synonyms and their definitions # b. Any dependancies # c. Blob Definitions # My current site does not employ most of these features. So I can # not really do anything with them since I cannot test them. # # 2: Needing more work is GetField(), which when given a qualifier for a # Datetime/Interval returns a field definition. This function is as per the # Reference manual dated 1991, and even my database has fields that are not # defined in there, such as minute(3), minute(4) and so on. Currently this # function will return minute for either of these. # # 3: Revisit the Parent/Child Table lookup and if there is a better way maybe someone # could enhance it. # # 4: Revisit the Reformat Function and add support for procedures and triggers as well. # This would allow links from within those pages to the tables being used. # # What should you do: # Create an html page however you like, containing names/links to each of the servers. # Since infmx2html.4ge can only work with the current server, if you have more than one # that you are running and building pages for you should have a toplevel page that # would be located in the 'root_directory' and allows you to easily get to each of the # Servers. # # So What Do You Get: A whole lotta html Pages. # # Basically when you run it you will get an entire # Web site dedicated to describing your Informix Server. # # # HEIRARCHY # / # | # | You should build this page # | | # | |->ServerName----------| # | | # | BlankPage.html | # | | # | InfmxTypes.html<------------+---------------------| # | | | | # | |->DataType | | # | |->Description | | # | |->ValidValues | | # | |->Aliases | | # | | | # |->/ | | # | | | # | DBNames.html<---------------| | # | | | # | |->ServerName ----------| | # | |->Database------------------| | # | |->Owner | | | # | |->DateCreated | | | # | |->Logging | | | # | |->ANSI Compliant? | | | # | |->NLS Enabled? | | | # | |->Read Only? | | | # | | | | # | | | | # | | | | # | Config.html<----------------| | | # | | | | # | |>Parameter | | # | |>Original Value | | # | |>Current Value | | # | |>Default Value | | # | | | # |->Databases/ | | # | | | # V | | # / | | # | | | # | Database.html <----------------| | # | | | # | |->Procedures------| | # | |->Triggers--------+------| | # | |->Tables----------+------+-----| | # | |->Views | | | | # | | | | | # | | | | | # | ProcIndex.html <------| | | | # | | | | | # | |->ProcName ------------| | | | # | |->ProcOwner | | | | # | |->ProcId | | | | # | |->ProcMode | | | | # | |->ProcArgCnt | | | | # | | | | | # | | | | | # | TrigIndex.html<-----------+--| | | # | | | | | # | |->TrigName-------------+-----| | | # | |->TrigOwner | | | | # | |->TrigId | | | | # | |->TrigTable------------+-----+------| | # | |->TrigEvent | | | | | # | |->TrigOld | | | | | # | |->TrigNew | | | | | # | |->Mode | | | | | # | | | | | | # | Views.html | | | | | # | | | | | | | # | |->ViewName-------------+-----+--+---+--| | # | |->Owner | | | | | | # | | | | | | | # | | | | | | | # | Tables.html<--------------+-----+--| | | | # | OwnerList.html | | | | | # | | | | | | | # | |->TableOwner-------| | | | | | # | |->TableCount | | | | | | # | | | | | | | # | | | | | | | # | TableIndex.html<-| | | | | | # | | | | | | | # | |->TableName----+-----+---| | | | # | | | | | | | # | | | | | | | # | | | | | | | # |->Procedures/ | | | | | | # | | | | | | | # | .txt<--| | | | | | # | | | | | | | # | |->ProcName | | | | | # | |->ProcOwner | | | | | # | |->ProcId | | | | | # | |->ProcBody | | | | | # | | | | | | # |->Triggers/ | | | | | # | | | | | | # | .txt <-----| | | | | # | | | | | | # | |->TrigName | | | | # | |->TrigOwner | | | | # | |->TrigId | | | | # | |->TrigTable | | | | # | |->TrigBody | | | | # | | | | | # |->Views/ | | | | # | | | | | # | .html<---------+--+--| | # | | | | | # | |->ViewName | | | # | |->Owner | | | # | |->CreateStatement---------| | | | # | | | | | # | | | | | # | | | | | # | | | | | # |->Tables/ | | | | # | | | | # -.html<-----|<-|<-|<-|<-| | # | | | | # | | | | # |->ParentTables--------------------| | | # |->ChildTable-------------------------| | # | | # |->UniqueIndexes | # |->DuplicateIndexes | # | | # |-> | # | | # |->ColNo | # |->ColName | # |->ColType-------------------------------| # |->ColDetail # |->ColLength # |->ColScale # |->ColNullsAllowed # |-> # # # # It will create all necessary Sub-Directorys as needed. # # # July 8 2002. Added check text to ownerTable.html pages to display text associated to a row or table level CHECK. # Tony Kaser Added linking from parent/child table names to the actual table being referenced. # Corrected problems with datatype length and scale. # Corrected display of default values for numeric datatypes. # This version is currently running with version 7.22 Informix Online. # # July 11 2002.Corrected a problem with the triggers index page. - I had not properly terminated a ' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X END IF X IF NewIdx = 4 THEN X PRINT COLUMN 13, 'No Parent Tables Found' X END IF X IF NewIdx = 5 THEN X PRINT COLUMN 13, 'No Child Tables Found' X END IF X END IF X X IF idx = 1 THEN X IF newIdx = 1 THEN X PRINT COLUMN 09, '' X PRINT COLUMN 11, '" X IF gr_sysindexes.clustered = 'C' THEN X PRINT COLUMN 11, '' X ELSE X PRINT COLUMN 11, '' X END IF X PRINT COLUMN 11, '' X PRINT ' " X PRINT ' " X PRINT ' ' X PRINT ' " X PRINT ' " X PRINT ' " X PRINT ' " X PRINT ' " X IF cd_Count = 1 X THEN X PRINT ' ' X END IF X PRINT ' ' X END IF X IF idx = 3 X THEN X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X PRINT COLUMN 09, '' X END IF X IF idx = 4 X THEN X PRINT COLUMN 09, '' X END IF X X ON LAST ROW X PRINT COLUMN 03, "" X PRINT COLUMN 01, "" X END REPORT X ############################################################################## # WHen you select a data type in from one of the table definitions you will # get this page which will give you some information about the datatype selected ############################################################################## REPORT DataTypes() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT X FIRST PAGE HEADER X PRINT "" X PRINT " " X PRINT " " X PRINT ' ' X PRINT '
' X PRINT '
field # Tony Kaser Changed the headings of the tables in the 'ownerTables.html' pagers to better indicate what # Data is contained in the htmlTable. # # July 15 2002.Added Functionality to allow program to build html pages for ALL the databases that you might # Tony Kaser have. User can, from the command line, select an individual database to build for. # System will now build for ALL databases except the sysmaster database, # User can now specify an HtmlRoot Directory to build the pages into. # Added check to see if tables 'tabdefs' and/or 'coldefs' exist. If they exist table pages will # Contain table definitions and/or column definitions when present. # See Cursors td_curs and cd_curs in PrepSqls for more information on these tables. # # July 18 2002.Corrected the above documentation. # Tony Kaser # # July 22 2002.Added support for Views. Views are being reformatted into html pages allowing links # Tony Kaser to the table(s) that they are created from. This is not perfect but it does work here. # X SHAR_EOF (set 20 02 09 20 08 09 29 'Readme.txt'; eval "$shar_touch") && chmod 0744 'Readme.txt' || $echo 'restore of' 'Readme.txt' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'Readme.txt:' 'MD5 check failed' c8789fe3437d03b916b22f8aca1938af Readme.txt SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Readme.txt'`" test 21187 -eq "$shar_count" || $echo 'Readme.txt:' 'original size' '21187,' 'current size' "$shar_count!" fi fi # ============= infmx2html.4gl ============== if test -f 'infmx2html.4gl' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'infmx2html.4gl' '(file already exists)' else $echo 'x -' extracting 'infmx2html.4gl' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'infmx2html.4gl' && DATABASE sysmaster GLOBALS X DEFINE gr_systables RECORD LIKE systables.* DEFINE gr_syscolumns RECORD LIKE syscolumns.* X DEFINE gr_syschecks RECORD X tabname CHAR(18), X constrname CHAR(18), X checktext CHAR(512) END RECORD X DEFINE gr_sysindexes RECORD LIKE sysindexes.* X END GLOBALS X # This is kind of a catch-all/Do-all Record DEFINE V RECORD X tabid INTEGER, X owner CHAR(8), X tabname CHAR(18), X idxname CHAR(18), X tabtype CHAR(15), X sequence SMALLINT, X colname CHAR(18), X colType CHAR(10), X collength INTEGER, X colScale INTEGER, X AllowNull CHAR(01), X SplType CHAR(20), X TheDefault LIKE SYSDEFAULTS.DEFAULT END RECORD X DEFINE CmdLine CHAR(256) DEFINE idxname CHAR(18) DEFINE newIdx INTEGER DEFINE tabname LIKE SYSTABLES.TABNAME DEFINE owner LIKE SYSTABLES.OWNER DEFINE MaxCols INTEGER DEFINE serverName LIKE sysconfig.cf_original X DEFINE rootDir CHAR(256) DEFINE curDir CHAR(512) DEFINE serverDir CHAR(256) DEFINE config_page CHAR(256) X X DEFINE buildAll SMALLINT DEFINE dbs ARRAY[100] of RECORD LIKE sysdatabases.* DEFINE theDB CHAR(20) DEFINE dbidx INTEGER DEFINE dbCount INTEGER X DEFINE td_Count INTEGER DEFINE cd_Count INTEGER DEFINE tbDesc CHAR(256) DEFINE colDesc CHAR(256) X ############################################################# ############################################################# MAIN X WHENEVER ERROR CONTINUE X LET rootDir = fgl_getenv("PWD") LET buildAll = 1 X IF ProcessArgs() = 1 THEN X CALL displayUsage() X EXIT PROGRAM END IF X CALL Main_Loop() X END MAIN X ############################################################# ############################################################# FUNCTION Main_Loop() DEFINE DBHtml CHAR(256) DEFINE errMsg CHAR(256) DEFINE tblCount INTEGER X # Get the name of the current server SELECT cf_effective INTO serverName FROM sysconfig WHERE cf_name = "DBSERVERNAME" X DISPLAY "Building Pages for Server : ", serverName CLIPPED X LET serverDir = rootDir CLIPPED, "/", serverName CLIPPED LET dbidx = 1 LET MaxCols = 4 X # Create the a directory for the current server LET CmdLine = "mkdir -p ", serverDir CLIPPED RUN CmdLine X # Create the Directory that will hold all the databases for the server LET curDir = serverDir CLIPPED, "/Databases/" LET CmdLine = "mkdir ", curDir CLIPPED RUN CmdLine X # DBHtml will be the main page that references the databases LET DBHtml = serverDir CLIPPED, "/DBNames.html" START REPORT dbIndex TO DBhtmL X #Build a couple Misc pages - BlankPage and InfmxTypes CALL BuildMiscPages() X # Build the server specific pages - currently only Config.html CALL BuildServerPage() X # Query sysdatabases for a list of databases being managed by this server # I do not include the sysmaster database in this list of databases CALL GetDatabases() X # Process Each database found. # dbCount is actually one greater than the number of databases found. WHILE dbidx < dbCount X # Open a connection to the database X DATABASE dbs[dbidx].name X # Verify that we can connect to the database X IF SQLCA.SQLCODE = 0 X THEN X # Add the database name to the html table of databases in DBNames.html X LET tblCount = 0 X SELECT COUNT(*) INTO tblCount X FROM systables X WHERE tabid > 99 X OUTPUT TO REPORT dbIndex(dbs[dbidx].*, tblCount, 0) X DISPLAY "Building pages for database : ", dbs[dbidx].name CLIPPED X # Create the directories for the current database pages X LET CmdLine = "rm -rf ", curDir CLIPPED, dbs[dbidx].name CLIPPED X RUN CmdLine X LET CmdLine = "mkdir ", curDir CLIPPED, dbs[dbidx].name CLIPPED X RUN CmdLine X LET CmdLIne = "mkdir ", curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Procedures" X RUN CmdLine X LET CmdLIne = "mkdir ", curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Tables" X RUN CmdLine X LET CmdLIne = "mkdir ", curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Triggers" X RUN CmdLine X LET CmdLIne = "mkdir ", curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Views" X RUN CmdLine X X CALL PrepSqls() # Prepare the SQLs for this database X CALL BuildFrameSet() # Build the main database page X CALL BuildOwnersList() # build the owners list page X CALL BuildProcsPages() # Build the html pages containing all procedures X CALL BuildTrigsPages() # Build the html pages for all the triggers X CALL BuildViewPages() X CALL BuildTablePages() # Now with all that out of the way, build the table pages. X X DISPLAY "Completed building pages for ", dbs[dbidx].name CLIPPED X DISPLAY "" X CLOSE DATABASE # Close the current database and move to the next one. X ELSE # If I could not connect to the database display a message indicating why X OUTPUT TO REPORT dbIndex(dbs[dbidx].*, 0, 1) X LET errMsg = ERR_GET(SQLCA.SQLCODE) X DISPLAY "Cannot build pages for database : ", dbs[dbidx].name CLIPPED X DISPLAY errMsg CLIPPED X END IF X LET dbidx = dbidx + 1 END WHILE X FINISH REPORT dbIndex X END FUNCTION X X ########################################### ########################################### FUNCTION ProcessArgs() DEFINE argCount SMALLINT DEFINE theArg CHAR(64) DEFINE idx SMALLINT DEFINE aFound SMALLINT DEFINE dFound SMALLINT X LET argCount = NUM_ARGS() LET aFound = 0 LET dFound = 0 X FOR idx = 1 TO argCount X LET theArg = ARG_VAL(idx) X CASE theArg X WHEN "-a" # Process All Databases X LET aFound = 1 X IF dFound = 1 X THEN X RETURN 1 X ELSE X LET buildAll = 1 X END IF X WHEN "-d" # Process only the indicated database X LET dFound = 1 X IF aFound = 1 X THEN X RETURN 1 X ELSE X LET idx = idx + 1 X LET theDB = ARG_VAL(idx) X LET buildAll = 0 X END IF X WHEN "-p" # Declare a directory for the top of the heirarchy X LET idx = idx + 1 X LET rootDir = ARG_VAL(idx) X LET CmdLine = "mkdir ", rootDir CLIPPED X RUN CmdLine X WHEN "-h" # Display the help/usage screen X RETURN 1 X END CASE END FOR X RETURN 0 END FUNCTION X ########################################### ########################################### FUNCTION displayUsage() DISPLAY " " DISPLAY "USAGE" DISPLAY " infmx2html [-a|-d dbName] [-p pathname] [-h]" DISPLAY "WHERE " DISPLAY " -a Build pages for ALL databases." DISPLAY " -d Build pages for selected database dbName." DISPLAY " -p Set base directory to pathname." DISPLAY " -h Display this help screen." DISPLAY " " DISPLAY " Options -a & -d are mutually exclusive and will cause program" DISPLAY " to abort without producing any pages." DISPLAY " " DISPLAY " Default is to build pages for ALL databases off the current directory" DISPLAY " " END FUNCTION X ########################################### ########################################### FUNCTION BuildServerPage() DEFINE config RECORD LIKE sysconfig.* DEFINE sql_stmt CHAR(256) X # Build a page containing the original/CURRENT/default configurations LET config_page = serverDir CLIPPED, "/Config.html" START REPORT configPage TO config_page X LET sql_stmt = "SELECT * ", X " FROM sysconfig ", X " ORDER BY cf_name " PREPARE cfg_prep FROM sql_stmt DECLARE cfg_curs CURSOR FOR cfg_prep X FOREACH cfg_curs INTO config.* X OUTPUT TO REPORT configPage(config.*) END FOREACH FINISH REPORT configPage X END FUNCTION X ########################################### ########################################### FUNCTION GetDatabases() DEFINE sql_stmt CHAR(256) X LET dbCount = 1 X LET sql_stmt = "SELECT * ", X " FROM sysdatabases", X " WHERE name != 'sysmaster'", X " ORDER BY name " X PREPARE db_prep FROM sql_stmt DECLARE db_curs CURSOR FOR db_prep X LET sql_stmt = "SELECT * ", X " FROM sysdatabases", X " WHERE name = ?" X PREPARE db2_prep FROM sql_stmt DECLARE db2_curs CURSOR FOR db2_prep X IF buildALL = 1 THEN X FOREACH db_curs INTO dbs[dbCount].* X LET dbCount = dbCount + 1 X IF dbCount > 90 X THEN X EXIT FOREACH X END IF X END FOREACH ELSE X OPEN db2_curs USING theDB X FETCH db2_curs INTO dbs[dbCount].* X CLOSE db2_curs X LET dbCount = 2 END IF X END FUNCTION X ########################################### ########################################### FUNCTION BuildMiscPages() DEFINE BlankFile CHAR(256) DEFINE TypesFile CHAR(256) X LET BlankFile = rootDir CLIPPED, "/BlankPage.html" START REPORT BlankPage TO BlankFile OUTPUT TO REPORT BlankPage() FINISH REPORT BlankPage X LET TypesFile = rootDir CLIPPED, "/InfmxTypes.html" START REPORT DataTypes TO TypesFile OUTPUT TO REPORT DataTypes() FINISH REPORT DataTypes END FUNCTION X ########################################### ########################################### FUNCTION PrepSqls() DEFINE sql_stmt CHAR(1000) X DISPLAY "Preparing cursors" X # This cursor will retreive a list of owners and how many # Tables the owner owns LET sql_stmt = "SELECT owner, count(*) ", X " FROM 'informix'.systables ", X " WHERE tabid > 99 ", X " GROUP BY owner ", X " ORDER BY owner " X PREPARE OwnerStmt FROM sql_stmt DECLARE OwnerCurs SCROLL CURSOR FOR OwnerStmt X # This cursor will retreive a list of tables owned by the 'owner' # LET sql_stmt = "SELECT * ", X " FROM 'informix'.systables ", X " WHERE tabid > 99 ", X " AND tabtype = 'T' ", X " AND owner = ? ", X " ORDER BY tabname " X PREPARE OwnerTablesStmt FROM sql_stmt DECLARE OwnersTableCurs CURSOR FOR OwnerTablesStmt X X X # This cursor will retrieve all database tables X # It WILL NOT return the informix system tables X LET sql_stmt = "SELECT * ", X "FROM 'informix'.systables ", X " WHERE tabid > 99 ", X " AND tabtype = 'T' ", X " ORDER BY owner, tabtype, tabname" X PREPARE SysStmt FROM sql_stmt DECLARE SysTab SCROLL CURSOR FOR SysStmt X LET sql_stmt = "SELECT a.tabname, a.owner, b.seqno, b.viewtext ", X " FROM 'informix'.systables a, ", X " 'informix'.sysviews b ", X " WHERE a.tabid > 99 ", X " AND a.tabtype = 'V' ", X " AND b.tabid = a.tabid ", X " ORDER BY a.tabname, b.seqno" X PREPARE ViewStmt FROM sql_stmt DECLARE ViewTab SCROLL CURSOR FOR ViewStmt X LET sql_stmt = "SELECT * ", X "FROM 'informix'.SYSINDEXES ", X "WHERE TABID = ? " X PREPARE SysIndexStmt FROM sql_stmt DECLARE SysIndex SCROLL CURSOR FOR SysIndexStmt X X LET sql_stmt = "SELECT * ", X "FROM 'informix'.SYSCOLUMNS ", X "WHERE TABID = ? ", X "ORDER BY COLNO " X PREPARE ColStmt FROM sql_stmt DECLARE ColTab SCROLL CURSOR FOR ColStmt X LET sql_stmt = "SELECT c.owner, c.tabname ", X "FROM 'informix'.sysconstraints a, ", X " 'informix'.sysreferences b, ", X " 'informix'.systables c ", X "WHERE a.tabid = ? ", X "AND a.constrid = b.constrid ", X "AND b.ptabid = c.tabid " X PREPARE ParentStmt FROM sql_stmt DECLARE ParentCurs CURSOR FOR ParentStmt X LET sql_stmt = "SELECT c.owner, c.tabname ", X "FROM 'informix'.sysconstraints a, ", X " 'informix'.sysreferences b, ", X " 'informix'.systables c ", X "WHERE b.ptabid = ? ", X "AND a.constrid = b.constrid ", X "AND c.tabid = a.tabid " X PREPARE ChildStmt FROM sql_stmt DECLARE ChildCurs CURSOR FOR ChildStmt X LET sql_stmt = "SELECT c.tabname, b.constrname, a.seqno, a.checktext", X " FROM syschecks a,", X " sysconstraints b,", X " systables c", X " WHERE c.tabid = ? ", X " AND b.tabid = c.tabid", X " AND a.constrid = b.constrid", X " AND a.type = 'T'", X " AND b.constrtype = 'C' ", X " ORDER BY 1, 2, 3" PREPARE CheckStmt FROM sql_stmt DECLARE CheckCurs CURSOR FOR CheckStmt X LET sql_stmt = "SELECT type, default ", X "FROM 'informix'.SYSDEFAULTS ", X "WHERE TABID = ? ", X " AND colno = ? " X PREPARE DefltStmt FROM sql_stmt DECLARE DefltCurs CURSOR FOR DefltStmt X SELECT COUNT(*) INTO td_Count X FROM systables X WHERE tabname = "tabdefs" X IF td_Count = 1 THEN X LET sql_stmt = "SELECT desc ", X "FROM tabdefs ", X "WHERE tabname = ? ", X "AND owner = ?" ELSE # The second query is only here to fool the program X LET sql_stmt = "SELECT null ", X "FROM systables ", X "WHERE tabname = ? ", X " AND owner = ? " END IF X PREPARE td_prep FROM sql_stmt X DECLARE td_curs CURSOR FOR td_prep X SELECT COUNT(*) INTO cd_Count X FROM systables X WHERE tabname = "coldefs" X IF cd_Count = 1 THEN X LET sql_stmt = "SELECT desc ", X " FROM coldefs ", X " WHERE tabname = ? ", X " AND owner = ? ", X " AND colname = ? " ELSE # The second query is only here to fool the program X LET sql_stmt = "SELECT null ", X " FROM syscolumns a, systables b ", X " WHERE b.tabid = a.tabid ", X " AND b.tabname = ? ", X " AND b.owner = ? ", X " AND a.colname = ? " END IF PREPARE cd_prep FROM sql_stmt DECLARE cd_curs CURSOR FOR td_prep X X END FUNCTION X X #################################################### # This function will define the file names and build # a set of pages containing Frames to navigate through # the pages yet to be build. #################################################### FUNCTION BuildFrameSet() DEFINE DataBaseFile CHAR(256) DEFINE ProcFile CHAR(256) DEFINE TrigFile CHAR(256) DEFINE TypeFile CHAR(256) DEFINE TableFile CHAR(256) DEFINE DBNavFile CHAR(256) DEFINE ViewFile CHAR(256) X DISPLAY "Building Framesets" X LET DataBaseFile = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Database.html" LET DBNavFile = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/DBNavBar.html" LET ProcFile = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Procedures.html" LET TrigFile = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Triggers.html" LET ViewFile = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Views.html" LET TableFile = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Tables.html" X START REPORT DataBaseFrames TO DataBaseFile OUTPUT TO REPORT DataBaseFrames() FINISH REPORT DataBaseFrames X START REPORT DBNav TO DBNavFile OUTPUT TO REPORT DBNav() FINISH REPORT DBNav X START REPORT ProcFrames TO ProcFile OUTPUT TO REPORT ProcFrames() FINISH REPORT ProcFrames X START REPORT TrigFrames TO TrigFile OUTPUT TO REPORT TrigFrames() FINISH REPORT TrigFrames X START REPORT ViewFrames TO ViewFile OUTPUT TO REPORT ViewFrames() FINISH REPORT ViewFrames X START REPORT TableFrames TO TableFile OUTPUT TO REPORT TableFrames() FINISH REPORT TableFrames X X END FUNCTION X #################################################### # This function will build a list of table owners with # Links to an HTML page containing an index of tables # Owned by the owner #################################################### FUNCTION BuildOwnersList() DEFINE OwnerHtml CHAR(256) DEFINE theOwner CHAR(8) DEFINE theQty INTEGER X DISPLAY "Building List Of Owners" LET OwnerHtml = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/OwnerList.html" X START REPORT OwnersIndex TO OwnerHtml FOREACH OwnerCurs INTO theOwner, theQty X OUTPUT TO REPORT OwnersIndex(theOwner, theQty) X CALL BuildABCIndex(theOwner) X CALL BuildHtmlIndex(TheOwner) END FOREACH X FINISH REPORT OwnersIndex X END FUNCTION X #################################################### # This function will build an indexed, table of # contents for the database pages. #################################################### FUNCTION BuildHtmlIndex(TheOwner) DEFINE theOwner CHAR(8) DEFINE CurChar CHAR(1) DEFINE TheHtmlPage CHAR(256) DEFINE idx INTEGER X LET CurChar = ' ' LET idx = 0 LET TheHtmlPage = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/", TheOwner CLIPPED, "TablesIndex.html" X START REPORT OwnerTableIndex TO TheHtmlPage X OPEN OwnersTableCurs USING TheOwner FETCH OwnersTableCurs INTO gr_systables.* WHILE SQLCA.SQLCODE = 0 X LET v.tabid = gr_systables.tabid X X LET v.tabname = UPSHIFT(gr_systables.tabname) X LET v.tabtype = TABTYPE(gr_systables.tabtype) X LET CurChar = v.tabname[1] X X OUTPUT TO REPORT OwnerTableIndex(TheOwner, CurChar, v.tabname) X X FETCH OwnersTableCurs INTO gr_systables.* X END WHILE X CLOSE OwnersTableCurs FINISH REPORT OwnerTableIndex X END FUNCTION X ############################################################### # Build the individual HTML pages # Each page will contain 4 html tables # 1st the Indexs that the tables uses # 2nd if found the parents and Children of the table # 3rd if found a table containing CHECKS and the text # 4rd the table definition itself ############################################################### FUNCTION BuildTablePages() DEFINE HTMLName CHAR(256) DEFINE PgCntr INTEGER X DISPLAY "Building Tables Pages" LET PgCntr = 0 X X FOREACH SysTab INTO gr_systables.* X LET PgCntr = PgCntr + 1 X LET v.tabid = gr_systables.tabid X LET v.tabname = UPSHIFT(gr_systables.tabname) X LET v.tabtype = TABTYPE(gr_systables.tabtype) X LET v.owner = gr_systables.owner X X LET HTMLName = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Tables/", v.owner CLIPPED, v.tabname CLIPPED, ".html" X START REPORT html TO HTMLName X X CALL GetIndexes() X CALL GetParentChild() X CALL GetChecks() X IF td_Count = 1 X THEN X INITIALIZE tbDesc TO null X CALL GetTBDesc() X OUTPUT TO REPORT html(v.*, 4) X END IF X X # GET Columns Data X OPEN ColTab USING gr_systables.tabid X FETCH ColTab INTO gr_syscolumns.* X WHILE SQLCA.SQLCODE = 0 X LET v.sequence = gr_syscolumns.colno X LET v.colname = gr_syscolumns.colname X CALL Col_Type(gr_syscolumns.collength, gr_syscolumns.coltype) X RETURNING v.coltype,v.collength,v.colscale,v.allownull, v.SplType X X CALL GetDefaults() RETURNING v.TheDefault X X IF cd_Count = 1 X THEN X INITIALIZE colDesc TO null X CALL GetColDesc() X END IF X X OUTPUT TO REPORT html(v.*, 2) X X FETCH ColTab INTO gr_syscolumns.* X END WHILE X CLOSE ColTab X FINISH REPORT html X END FOREACH X DISPLAY "Built ", PgCntr USING "<<<<<<&", " Table Pages" X END FUNCTION X ############################################################ ############################################################ FUNCTION BuildViewPages() DEFINE tabname LIKE 'informix'.systables.tabname DEFINE seqno LIKE 'informix'.sysviews.seqno DEFINE owner LIKE 'informix'.systables.owner DEFINE l_tabname LIKE 'informix'.systables.tabname DEFINE l_owner LIKE 'informix'.systables.owner DEFINE ViewPage CHAR(256) DEFINE ViewList CHAR(256) DEFINE Viewtext LIKE 'informix'.sysviews.viewtext DEFINE VText CHAR(1000) DEFINE Reformatted CHAR(3000) DEFINE vidx INTEGER DEFINE l_stat INTEGER X INITIALIZE Reformatted TO NULL INITIALIZE ViewText TO NULL INITIALIZE VText TO NULL DISPLAY "Building Views Pages" LET l_stat = 0 LET ViewList = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/ViewIndex.html" START REPORT ViewIndexRpt TO ViewList X OPEN ViewTab FETCH ViewTab INTO l_tabname, l_owner, seqno, VText X LET l_stat = SQLCA.SQLCODE #DISPLAY "View Found : ", l_tabname CLIPPED #DISPLAY "1 ViewText ", VText CLIPPED X IF l_stat != 0 THEN X LET l_tabname = "None Found" X LET l_owner = "N/A" END IF X OUTPUT TO REPORT ViewIndexRpt(l_tabname, l_owner) X WHILE l_stat = 0 X FETCH ViewTab INTO tabname, owner, seqno, ViewText X LET l_stat = SQLCA.SQLCODE X X IF l_stat = 0 X THEN X #DISPLAY "2 ViewText ", ViewText CLIPPED X # If we got here we have now performed 2 FETCHS Successfully X IF seqno = 0 X THEN X OUTPUT TO REPORT ViewIndexRpt(l_tabname, l_owner) X LET ViewPage = curDir CLIPPED, dbs[dbidx].name CLIPPED, '/Views/', X l_owner CLIPPED, UPSHIFT(l_tabname) CLIPPED, '.html' X START REPORT theView TO ViewPage X X #DISPLAY "1 Calling Reformat with <", VText CLIPPED, ">" X X LET Reformatted = Reformat(VText) X X OUTPUT TO REPORT theView(l_tabname, l_owner, Reformatted) X FINISH REPORT theView X X INITIALIZE Reformatted TO NULL X INITIALIZE VText TO NULL X LET l_tabname = tabname X LET l_owner = owner X LET VText = ViewText CLIPPED X INITIALIZE ViewText TO NULL X ELSE X LET VText = VText CLIPPED, ViewText X END IF X ELSE X LET ViewPage = curDir CLIPPED, dbs[dbidx].name CLIPPED, '/Views/', X l_owner CLIPPED, UPSHIFT(l_tabname) CLIPPED, '.html' X START REPORT theView TO ViewPage X #DISPLAY "seqno = ", seqno USING "&&&" X #DISPLAY "2 Calling Reformat with <", VText CLIPPED, ">" X LET Reformatted = Reformat(VText) X OUTPUT TO REPORT theView(l_tabname, l_owner, Reformatted) X INITIALIZE Reformatted TO NULL X INITIALIZE ViewText TO NULL X INITIALIZE VText TO NULL X FINISH REPORT theView X END IF X END WHILE X CLOSE ViewTab FINISH REPORT ViewIndexRpt X END FUNCTION X X ############################################################ ############################################################ FUNCTION Reformat(theText) DEFINE theText CHAR(2048) DEFINE rText CHAR(3000) DEFINE i INTEGER DEFINE theWord CHAR(128) DEFINE endWord SMALLINT DEFINE startParen SMALLINT DEFINE endParen SMALLINT DEFINE inParen SMALLINT DEFINE isOwner SMALLINT DEFINE tableNext SMALLINT DEFINE isFrom SMALLINT DEFINE isDone SMALLINT DEFINE owner CHAR(8) DEFINE tbl CHAR(18) DEFINE isDot SMALLINT DEFINE isTable SMALLINT DEFINE dspChar CHAR(1) DEFINE afterDot SMALLINT DEFINE isView SMALLINT DEFINE isSelect SMALLINT DEFINE isProcedure SMALLINT X LET endWord = 0 LET startParen = 0 LET endParen = 0 LET inParen = 0 LET isOwner = 0 LET tableNext = 0 LET isFrom = 0 LET isDone = 0 LET isDot = 0 LET isTable = 0 LET afterDot = 0 LET isView = 0 LET isSelect = 0 LET isProcedure = 0 X INITIALIZE theWord TO NULL INITIALIZE rText TO NULL LET rText = "" X FOR i = 1 to LENGTH(theText) X IF startParen = 1 X THEN X LET inParen = 1 X LET startParen = 0 X END IF X CASE theText[i] X WHEN '(' X LET endWord = 1 X LET startParen = 1 X WHEN ')' X LET endWord = 1 X LET endParen = 1 X LET inParen = 0 X WHEN ' ' X LET endWord = 1 X WHEN '"' X LET endWord = 1 X IF isOwner = 0 X THEN X LET isOwner = 1 X END IF X WHEN ';' X LET isDone = 1 X LET endWord = 1 X WHEN ',' X LET endWord = 1 X WHEN '.' X LET isDot = 1 X LET endWord = 1 X OTHERWISE X LET endWord = 0 X IF tableNext = 1 X THEN X LET tableNext = 0 X LET isTable = 1 X END IF X LET theWord = theWord CLIPPED, theText[i] X END CASE X IF endWord = 1 X THEN X LET dspChar = theText[i] X # I found that informix will return the view statement in lowercase regardless X # of whether or not I use UPPER CASE or lower when I write it. X CASE theWord X WHEN 'create' X LET theWord = 'CREATE' X WHEN 'view' X LET theWord = ' VIEW' X LET isView = 1 X WHEN 'as' X LET theWord = '
AS
' X WHEN 'select' X LET theWord = '
SELECT' X LET isSelect = 1 X WHEN 'unique' X LET theWord = ' UNIQUE' X LET isSelect = 0 X WHEN 'distinct' X LET theWord = ' DISTINCT' X LET isSelect = 0 X WHEN 'from' X LET theWord = '
FROM
' X LET isSelect = 0 X WHEN 'where' X LET theWord = '
WHERE' X LET isSelect = 0 X WHEN 'and' X LET theWord = ',
AND' X LET isSelect = 0 X WHEN 'or' X LET theWord = ',
OR' X LET isSelect = 0 X WHEN 'union' X LET theWord = '
UNION
' X LET isSelect = 0 X WHEN 'group' X LET theWord = '
GROUP' X LET isSelect = 0 X WHEN 'with' X LET theWord = '
WITH' X LET isSelect = 0 X WHEN 'check' X LET theWord = ' CHECK' X LET isSelect = 0 X WHEN 'option' X LET theWord = ' OPTION' X LET isSelect = 0 X WHEN 'order' X LET theWord = '
ORDER' X LET isSelect = 0 X WHEN 'by' X LET theWord = ' BY' X LET isSelect = 0 X END CASE X CASE X WHEN isOwner = 1 X LET owner = theWord CLIPPED X LET theWord = '' X LET isOwner = 0 X LET tableNext = 1 X WHEN isTable = 1 AND isDot = 0 X LET isTable = 0 X LET tbl = UPSHIFT(theWord) X IF isView = 1 # If this table is a view I do not want to try to add a link to it. X THEN X LET rText = rText CLIPPED, ' "', owner CLIPPED, '".', theWord CLIPPED X LET isView = 0 X ELSE X LET rText = rText CLIPPED, X ' "', owner CLIPPED, '".', theWord CLIPPED, ' ' X END IF X LET theWord = '' X LET isTable = 0 X LET afterDot = 0 X WHEN isDot = 1 X IF tableNext = 0 X THEN X LET rText = rText CLIPPED, " ", theWord CLIPPED, "." X END IF X LET theWord = '' X LET isDot = 0 X LET afterDot = 1 X WHEN startParen = 1 X LET rtext = rText CLIPPED, " ", theWord CLIPPED, "(
" X LET theWord = '' X WHEN inParen = 1 X LET rtext = rText CLIPPED, ' ', theWord CLIPPED, ",
" X LET theWord = '' X WHEN endParen = 1 X LET rtext = rText CLIPPED, ' ', theWord CLIPPED, "
)
" X LET theWord = '' X LET endParen = 0 X WHEN isSelect AND theText[i,i] = ',' X LET rText = rText CLIPPED, theWord CLIPPED, ',
' X OTHERWISE X IF afterDot = 1 X THEN X LET rText = rText CLIPPED, theWord CLIPPED X LET afterDot = 0 X ELSE X LET rText = rText CLIPPED, " ", theWord CLIPPED X END IF X LET theWord = '' X END CASE X END IF END FOR X LET rText = rText CLIPPED, "
" RETURN rText X END FUNCTION X X X ############################################################ ############################################################ FUNCTION GetTBDesc() X OPEN td_curs USING gr_systables.tabid, gr_systables.owner FETCH td_curs INTO tbDesc X IF SQLCA.SQLCODE <> 0 THEN X LET tbDesc = "No Description Found" END IF X CLOSE td_curs X END FUNCTION X ############################################################ ############################################################ FUNCTION GetColDesc() X OPEN cd_curs USING gr_systables.tabid, gr_systables.owner, gr_syscolumns.colname FETCH cd_curs INTO colDesc X IF SQLCA.SQLCODE <> 0 THEN X LET colDesc = "No Description Found" END IF X CLOSE cd_curs X END FUNCTION X ############################################################ ############################################################ FUNCTION BuildABCIndex(Owner) DEFINE Owner CHAR(8) DEFINE TheChars CHAR(26) DEFINE idx INTEGER DEFINE TheChar CHAR(1) DEFINE OutHTML CHAR(256) X LET OutHTML = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/", Owner CLIPPED, "_Index.html" X LET TheChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" X X START REPORT OwnerABCIndex TO OutHTML X FOR idx = 1 TO 26 X LET TheChar = TheChars[idx] X OUTPUT TO REPORT OwnerABCIndex(Owner, TheChar) X END FOR X FINISH REPORT OwnerABCIndex X END FUNCTION X X X ############################################################ ############################################################ FUNCTION GetParentChild() DEFINE Parent LIKE SYSTABLES.tabname DEFINE l_stat INTEGER X X LET NewIdx = 0 X OUTPUT TO REPORT html(v.*, 0) X OPEN ParentCurs USING v.tabid X FETCH ParentCurs INTO owner, tabname X LET l_stat = SQLCA.SQLCODE X IF l_stat = 100 THEN X LET NewIdx = 4 # No Parent Tables Found X OUTPUT TO REPORT html(v.*, 0) X END IF X LET NewIdx = 2 X WHILE l_stat = 0 X OUTPUT TO REPORT html(v.*, 0) X FETCH ParentCurs INTO owner, tabname X LET l_stat = SQLCA.SQLCODE X END WHILE X CLOSE ParentCurs X LET NewIdx = 3 X X LET NewIdx = 1 X OUTPUT TO REPORT html(v.*, 0) X OPEN ChildCurs USING v.tabid X FETCH ChildCurs INTO owner, tabname X LET l_stat = SQLCA.SQLCODE X IF l_stat = 100 THEN X LET NewIdx = 5 # No Child Tables Found X OUTPUT TO REPORT html(v.*, 0) X END IF X LET NewIdx = 2 X WHILE l_stat = 0 X OUTPUT TO REPORT html(v.*, 0) X FETCH ChildCurs INTO owner, tabname X LET l_stat = SQLCA.SQLCODE X END WHILE X CLOSE ChildCurs END FUNCTION X ############################################################ ############################################################ FUNCTION getIndexes() DEFINE IdxType CHAR(1) X X OPEN SysIndex USING v.tabid X FETCH SysIndex INTO gr_sysindexes.* X X WHILE SQLCA.SQLCODE = 0 X LET newIdx = 1 X X LET v.tabid = gr_sysindexes.tabid X { Get the table usage description } X X LET v.idxname = UPSHIFT(gr_sysindexes.idxname) X LET v.tabtype = TABTYPE(gr_sysindexes.idxtype) X { Part1 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part1) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 01 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X LET newIdx = 0 X X { Part2 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part2) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence =02 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X X { Part3 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part3) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 03 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X X { Part4 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part4) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 04 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X X { Part5 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part5) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 05 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X X { Part6 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part6) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 06 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X X { Part7 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part7) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 07 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X X { Part8 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part8) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 08 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part9 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part9) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 09 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part10 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part10) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 10 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part11 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part11) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 11 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part12 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part12) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 12 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part13 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part13) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 13 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part14 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part14) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 14 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part15 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part15) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 15 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X { Part16 } X CALL GET_COL(gr_sysindexes.tabid, X gr_sysindexes.part16) RETURNING STATUS X IF STATUS = 0 THEN X LET v.sequence = 16 X LET v.colname = gr_syscolumns.colname X OUTPUT TO REPORT html(v.*, 1) X END IF X FETCH SysIndex INTO gr_sysindexes.* X X X END WHILE X LET v.idxname = " " X CLOSE SysIndex END FUNCTION X ############################################################ ############################################################ FUNCTION GetChecks() DEFINE l_stat INTEGER DEFINE tabname CHAR(18) DEFINE constrname CHAR(18) DEFINE chktext CHAR(1024) DEFINE seqno INTEGER X LET l_stat = 0 X OPEN CheckCurs USING v.tabid X FETCH CheckCurs INTO gr_syschecks.tabname, gr_syschecks.constrname, X seqno, gr_syschecks.checktext X LET l_stat = SQLCA.SQLCODE X WHILE l_stat = 0 X FETCH CheckCurs INTO tabname, constrname, seqno, chktext X LET l_stat = SQLCA.SQLCODE X IF l_stat = 0 X THEN X # If we got here we have now performed 2 FETCHS Successfully X IF seqno = 0 X THEN X OUTPUT TO REPORT html(v.*, 3) X LET gr_syschecks.tabname = tabname X LET gr_syschecks.constrname = constrname X LET gr_syschecks.checktext = chktext X ELSE X LET gr_syschecks.checktext = gr_syschecks.checktext CLIPPED, chktext CLIPPED X END IF X ELSE X OUTPUT TO REPORT html(v.*, 3) X END IF X END WHILE X CLOSE CheckCurs END FUNCTION X X ############################################################ ############################################################ FUNCTION GetDefaults() DEFINE TheType LIKE SYSDEFAULTS.TYPE DEFINE TheDefault LIKE SYSDEFAULTS.DEFAULT DEFINE tempVal LIKE SYSDEFAULTS.DEFAULT DEFINE tVal LIKE SYSDEFAULTS.DEFAULT DEFINE idx INTEGER DEFINE val_start SMALLINT X LET val_start = 0 X X OPEN DefltCurs USING v.tabid, gr_syscolumns.colno X FETCH DefltCurs INTO TheType, TheDefault X IF SQLCA.SQLCODE != 0 THEN X LET TheDefault = "No Default Value" X RETURN TheDefault X END IF X CLOSE DefltCurs X X CASE TheType X WHEN 'U' LET TheDefault = 'USER DEFAULT VALUE' X WHEN 'C' LET TheDefault = 'The CURRENT DataTime' X WHEN 'N' LET TheDefault = 'NULL' X WHEN 'T' LET TheDefault = 'TODAY' X WHEN 'S' LET TheDefault = 'DBSERVERNAME' X WHEN 'L' X LET tVal = TheDefault CLIPPED X INITIALIZE tempVal TO NULL X IF v.coltype != "CHAR" X THEN X FOR idx = 1 TO LENGTH(tVal) X IF tVal[idx] = " " AND val_start = 0 X THEN X LET val_start = 1 X CONTINUE FOR X END IF X IF val_start > 0 AND (tVal[idx] < " " OR tVal[idx] > "~") X THEN X EXIT FOR X END IF X IF val_start > 0 X THEN X LET tempVal[val_start] = tVal[idx] X LET val_start = val_start + 1 X END IF X END FOR X LET TheDefault = tempVal CLIPPED X END IF X END CASE X RETURN TheDefault END FUNCTION X X ############################################################ ############################################################ { Return ColType, IsNull,Length, Scale for Decimals or Money Values } FUNCTION Col_Type(pcollen,Arg) DEFINE pcollen, {Coll Length Sent via parameter} X Arg INTEGER , X TypeReturn CHAR(10), {ColType} X Allow_Null CHAR(01), {IsNull } X LenReturn INTEGER, {Length } X ScaReturn INTEGER {Scale } DEFINE TheType CHAR(20) DEFINE TheLargest CHAR(12) X DEFINE TheSmallest CHAR(12) DEFINE TheLength INTEGER DEFINE LargestQ INTEGER DEFINE SmallestQ INTEGER X LET TheLength = pcollen / 256 LET LargestQ = (pcollen MOD 256) / 16 LET SmallestQ = (pcollen MOD 256) MOD 16 LET TheType = ' ' X X X { Calculate IS NULL } X IF Arg >= 256 THEN X LET Allow_Null = 'N' X LET Arg = Arg - 256 X ELSE X LET Allow_Null = 'Y' X END IF X X LET ScaReturn = 0 X LET LenReturn = pcollen X X { Calculate ColType } X CASE Arg X WHEN 0 LET TypeReturn = 'CHAR ' X WHEN 1 LET TypeReturn = 'SMALLINT ' X WHEN 2 LET TypeReturn = 'INTEGER ' X WHEN 3 LET TypeReturn = 'FLOAT ' X WHEN 4 LET TypeReturn = 'SMALLFLOAT' X WHEN 5 LET TypeReturn = 'DECIMAL ' X CALL LenScale(pcollen) RETURNING LenReturn,ScaReturn X WHEN 6 LET TypeReturn = 'SERIAL ' X WHEN 7 LET TypeReturn = 'DATE ' X WHEN 8 LET TypeReturn = 'MONEY ' X CALL LenScale(pcollen) RETURNING LenReturn,ScaReturn X WHEN 9 LET TypeReturn = 'NULL ' #This one is not listed in the book as being used. X WHEN 10 LET TypeReturn = 'DATETIME ' X LET TheType = GetField(LargestQ) CLIPPED, " To ", GetField(SmallestQ) CLIPPED X LET LenReturn = TheLength X WHEN 11 LET TypeReturn = 'BYTE ' X WHEN 12 LET TypeReturn = 'TEXT ' X WHEN 13 LET TypeReturn = 'VARCHAR ' X CALL LenScale(pcollen) RETURNING LenReturn,ScaReturn X WHEN 14 LET TypeReturn = 'INTERVAL ' X LET TheType = GetField(LargestQ) CLIPPED, " To ", GetField(SmallestQ) CLIPPED X LET LenReturn = TheLength X WHEN 15 LET TypeReturn = 'NCHAR ' X WHEN 16 LET TypeReturn = 'NVARCHAR ' X CALL LenScale(pcollen) RETURNING LenReturn,ScaReturn X OTHERWISE LET TypeReturn = 'UNDEFINED ' X END CASE X X RETURN TypeReturn, LenReturn, ScaReturn, Allow_Null, TheType END FUNCTION X ############################################################ ############################################################ FUNCTION GetField(Qualifier) DEFINE Qualifier INTEGER DEFINE RetVal CHAR(12) X X CASE Qualifier X WHEN 0 LET RetVal = "YEAR" X WHEN 2 LET RetVal = "MONTH" X WHEN 4 LET RetVal = "DAY" X WHEN 6 LET RetVal = "HOUR" X WHEN 8 LET RetVal = "MINUTE" X WHEN 10 LET RetVal = "SECOND" X WHEN 11 LET RetVal = "FRACTION(1)" X WHEN 12 LET RetVal = "FRACTION(2)" X WHEN 13 LET RetVal = "FRACTION(3)" X WHEN 14 LET RetVal = "FRACTION(4)" X WHEN 15 LET RetVal = "FRACTION(5)" X OTHERWISE X LET RetVal = Qualifier USING "####&" X END CASE X RETURN RetVal X END FUNCTION X ############################################################ ############################################################ FUNCTION LenScale(dividendo) X X DEFINE X X Dividendo, X Len, X Scale INTEGER X X LET Scale = dividendo MOD 256 X LET Len = (dividendo - Scale)/256 X X RETURN Len,Scale X END FUNCTION X X ############################################################ ############################################################ FUNCTION TABTYPE(Arg) X DEFINE Arg CHAR(01), X ArgReturn CHAR(15) X X CASE Arg X WHEN 'T' LET ArgReturn = 'TABLE' X WHEN 'V' LET ArgReturn = 'VIEW ' X WHEN 'S' LET ArgReturn = 'SYNONYM' X WHEN 'P' LET ArgReturn = 'PRIVATE SYNONYM' X WHEN 'U' LET ArgReturn = 'UNIQUE INDEX' X WHEN 'D' LET ArgReturn = 'DUPLICATE INDEX' X END CASE X RETURN ArgReturn END FUNCTION X ############################################################ ############################################################ FUNCTION GET_COL(ltabid,lcolno) X DEFINE ltabid INTEGER, X lcolno SMALLINT X X X SELECT * INTO gr_syscolumns.* X FROM SYSCOLUMNS X WHERE TABID = ltabid X AND colno = lcolno X X RETURN STATUS END FUNCTION X ############################################################ REPORT configPage(config) DEFINE config RECORD LIKE sysconfig.* X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X FORMAT X FIRST PAGE HEADER X PRINT "" X PRINT " " X PRINT " Server Configurations For Server :", serverName CLIPPED, "" X PRINT " " X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X ON EVERY ROW X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X X ON LAST ROW X PRINT '
SERVER : ', X serverName CLIPPED, '
Last Updated : ', TODAY USING "ddd, mmm.dd, yyyy", X '
' X PRINT '
PARAMETER
CURRENT
VALUE
ORIGINAL
VALUE
DEFAULT
VALUE
',config.cf_name CLIPPED, '', config.cf_effective CLIPPED, '', config.cf_original CLIPPED, '', config.cf_default CLIPPED, '
' X PRINT '
' X PRINT ' ' X PRINT '' X END REPORT X X X ############################################################ # The sysdatabases table has different fields depending on the engine # you are running. However it appears that the flags are the same # So I decided to use the flags to make these determinations # sysdatabases.flags = 0 = no logging # sysdatabases.flags = 1 = unbuffered logging # sysdatabases.flags = 2 = buffered loging # sysdatabases.flags = 4 = ansi compliant database # sysdatabases.flags = 8 = read only # sysdatabases.flags = 16 = nls database ############################################################ REPORT dbIndex(curDB, tblCount, noPerm) DEFINE curDB RECORD LIKE sysdatabases.* DEFINE tblCount INTEGER DEFINE noPerm SMALLINT DEFINE logging CHAR(30) DEFINE ansi CHAR(1) DEFINE nls CHAR(1) DEFINE read_only CHAR(1) DEFINE log_level SMALLINT X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X FORMAT X FIRST PAGE HEADER X PRINT "" X PRINT " " X PRINT " Databases" X PRINT " " X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X ON EVERY ROW X LET log_level = (curDB.flags MOD 4) X CASE log_level X WHEN 3 LET logging = "Buffered
Unbuffered" X WHEN 2 LET logging = "Buffered" X WHEN 1 LET logging = "Un-Buffered" X WHEN 0 LET logging = "No Logging" X END CASE X X IF ((curDB.flags MOD 8)/4) = 1 X THEN X LET ansi = "Y" X ELSE X LET ansi = "N" X END IF X X IF curDB.flags/16 = 1 X THEN X LET nls = "Y" X ELSE X LET nls = "N" X END IF X X IF ((curDB.flags MOD 16)/8) = 1 X THEN X LET read_only = "Y" X ELSE X LET read_only = "N" X END IF X IF noPerm = 0 X THEN X PRINT ' ' X PRINT ' ' X ELSE X PRINT ' ' X PRINT ' ' X END IF X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X ON LAST ROW X PRINT '
Databases For Server :' X PRINT ' ', serverName CLIPPED, '
' X PRINT '
Pages Last Updated : ', X TODAY USING "ddd, mmm. dd, yyyy", '
DATABASE
TABLE
COUNT
OWNER
DATE CREATED
LOGGING
ANSI
COMPLIANT?
NLS
ENABLED?
READ
ONLY?
', curDB.name CLIPPED, '
', curDB.name CLIPPED, '', tblCount USING "####&", '', curDB.owner CLIPPED, '', curDB.created USING "ddd, mmm. dd, yyyy", '', logging CLIPPED, '', ansi, '', nls, '', read_only, '
' X PRINT ' **DATABASES HIGHTED IN RED COULD NOT BE ACCESSED**' X PRINT '
' X PRINT ' ' X PRINT '' X END REPORT X X ############################################################ # This report creates an html page containing a list of ALL owners # in the database selected. Each owner name is linked to an HTML # page containing an 'ABC' index. ############################################################ REPORT OwnersIndex(Owner, Qty) DEFINE Owner CHAR(8) DEFINE Qty INTEGER DEFINE idx INTEGER X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X ORDER EXTERNAL BY Owner X FORMAT FIRST PAGE HEADER X LET idx = 0 X PRINT "" X PRINT " " X PRINT " " X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X ON EVERY ROW X IF idx = 0 THEN X PRINT ' ' X END IF X PRINT ' ' X PRINT ' ' X LET idx = idx + 1 X IF idx = 3 THEN X PRINT ' ' X LET idx = 0 X END IF X ON LAST ROW X IF idx != 0 THEN X PRINT " " X ELSE X PRINT X END IF X PRINT "
OWNER NAME
TABLE COUNT
OWNER NAME
TABLE COUNT
OWNER NAME
TABLE COUNT
', X '
', Owner CLIPPED, '
', Qty USING "####&", '
" X PRINT "
" X PRINT " " X PRINT "" X END REPORT X ############################################################ # This function creates an html page that contains the "ABC" index # For the specified Owner. ############################################################ REPORT OwnerABCIndex(Owner, TheChar) DEFINE Owner CHAR(8) DEFINE TheChar CHAR(1) DEFINE idx INTEGER X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X FORMAT FIRST PAGE HEADER X LET idx = 0 X PRINT "" X PRINT " " X PRINT " " X PRINT ' ' X PRINT '
' X PRINT ' OWNER: ',Owner CLIPPED, '' X PRINT ' ' X PRINT ' ' X ON EVERY ROW X PRINT ' ' X ON LAST ROW X PRINT " " X PRINT "
' X PRINT '
' X PRINT ' ', TheChar, '' X PRINT '
' X PRINT '
" X PRINT "
" X PRINT " " X PRINT "" X END REPORT X ############################################################ # This Report creates an HTML page containing the table index # scheme for the given owner/table ############################################################ REPORT OwnerTableIndex(Owner, TheChar, TabName) DEFINE Owner CHAR(8) DEFINE TheChar CHAR(1) DEFINE TabName CHAR(18) DEFINE idx SMALLINT DEFINE FillVal SMALLINT X X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X ORDER EXTERNAL BY TheChar X FORMAT FIRST PAGE HEADER X LET idx = 0 X PRINT "" X PRINT " " X PRINT " " X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X BEFORE GROUP OF TheChar X LET FillVal = MaxCols - idx X X IF FillVal > 0 AND FillVal < MaxCols THEN X PRINT ' ' X PRINT ' ' X PRINT ' ' X END IF X PRINT ' ' X PRINT ' ' X LET idx = 0 X ON EVERY ROW X IF idx = 0 THEN X PRINT ' ' X END IF X PRINT ' ' X LET idx = idx + 1 X IF idx = MaxCols THEN X PRINT ' ' X LET idx = 0 X END IF X ON LAST ROW X PRINT ' ' X PRINT '
' X PRINT '
', TheChar, '
' X PRINT '
' X PRINT ' ', TabName CLIPPED, '' X PRINT '
' X PRINT '
' X PRINT ' ' X PRINT '' X END REPORT X ############################################################ # This Report creates an HTML page containing the table specific # scheme for the given owner/table ############################################################ REPORT html(v, idx) DEFINE V RECORD X tabid INTEGER, X owner CHAR(8), X tabname CHAR(18), X idxname CHAR(18), X tabtype CHAR(15), X sequence SMALLINT, X colname CHAR(18), X colType CHAR(10), X collength INTEGER, X colScale INTEGER, X AllowNull CHAR(01), X SplType CHAR(20), X TheDefault LIKE SYSDEFAULTS.default X END RECORD DEFINE tn CHAR(18) DEFINE idx INTEGER DEFINE lcklvl CHAR(6) X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X ORDER EXTERNAL BY idx X FORMAT FIRST PAGE HEADER X INITIALIZE idxname TO NULL X PRINT "" X PRINT " " X PRINT " TABLE : ",v.tabname CLIPPED, "" X PRINT " " X PRINT ' ' X BEFORE GROUP OF idx X PRINT COLUMN 05, "
" X PRINT COLUMN 07, '' X IF idx = 0 X THEN X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X PRINT COLUMN 09, '' X END IF X IF idx = 1 X THEN X IF gr_systables.locklevel = 'R' X THEN X LET lcklvl = "ROW" X ELSE X LET lcklvl = "TABLE" X END IF X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X PRINT COLUMN 09, '' X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X PRINT COLUMN 09, '' X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X PRINT COLUMN 09, '' X END IF X IF idx = 2 X THEN X IF cd_Count = 1 X THEN X PRINT COLUMN 09, '' X ELSE X PRINT COLUMN 09, '' X END IF X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X IF cd_Count = 1 X THEN X PRINT ' ' X END IF X PRINT " " X END IF X IF idx = 3 X THEN X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X PRINT COLUMN 09, '' X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X PRINT COLUMN 11, '' X PRINT COLUMN 09, '' X END IF X IF idx = 4 X THEN X PRINT COLUMN 09, '' X PRINT COLUMN 11, '' X END IF X X X AFTER GROUP OF idx X IF idx < 2 THEN X PRINT COLUMN 11, "" X PRINT COLUMN 09, "" X END IF X PRINT COLUMN 05, "
PARENT/CHILDREN
TABLE NAME:',v.tabname CLIPPED, '
LOCK LEVEL:', lcklvl CLIPPED, '
INDEXES
Index TypeTable NameClusteringIndex Name
COLUMN DEFINITIONS
COLUMN DEFINITIONS
COLUMN#COLUMN
NAME
TYPESPECIALLENGTHSCALENULLS?DEFAULT VALUEDEFINITION
CHECKS
CONSTRAINT NAME
CHECK TEXT
TABLE DEFINITION
" X PRINT COLUMN 05, "
" X ON EVERY ROW X IF idx = 0 THEN X IF newIdx = 0 THEN X PRINT COLUMN 09, '
PARENT TABLES' X END IF X IF NewIdx = 1 THEN X PRINT COLUMN 09, '
CHILD TABLES' X END IF X IF NewIdx = 2 THEN X LET tn = UPSHIFT(tabname) X PRINT COLUMN 13, '
"', owner CLIPPED, '".', tabname CLIPPED, '' X END IF X IF NewIdx = 3 THEN X PRINT COLUMN 15, '
' X PRINT COLUMN 13, '
',V.tabtype CLIPPED, '', v.tabname CLIPPED, " CLUSTERED NON-CLUSTERED' X LET idxname = v.idxname X END IF X PRINT COLUMN 10, v.colname CLIPPED X PRINT COLUMN 10, "
" X END IF X X IF idx = 2 THEN X PRINT '
',v.sequence USING "##&", "', v.colname CLIPPED, "',v.coltype clipped, '', v.SplType CLIPPED, "', v.collength USING "###&", "', v.colscale USING "###&", "', v.allownull CLIPPED, "', v.Thedefault CLIPPED, "', colDesc CLIPPED, '
', gr_syschecks.constrname CLIPPED, '', gr_syschecks.checktext CLIPPED, '
',tbDesc CLIPPED, '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X ON LAST ROW X PRINT ' ' X PRINT '
Data TypeDescriptionValid ValuesAliases
SMALLINTThis data type includes whole numbers-32,767 to +32,767NONE
INTEGERThis data type includes whole numbers-2,147,483,647 TO +2,147,483,647INT
DECIMAL[(m[,n])]This data type includes decimal floating-point numbers Precision = m(<=32), Scale = n (<=m)DEC, NUMERIC
SMALLFLOATThis data type includes binary floating-point numbers corresponding to the float type of the C language. .REAL
FLOAT[(n)]This data type includes binary floating-point numbers corresponding to the double type of the C language. .DOUBLE PRECISION
MONEY[(m [,n])]The money data type is just like the type DECIMAL But variable of the type MONEY are displayed with a currency sign. MONEY(m) Is the same as MONEY(m, 2). MONEY Is the same as MONEY(16, 2).
CHAR [(n)]These are cahracter strings of length n, where n <= 32,767 CHARACTER
DATEThese are dates from a DATE column or expression. DATE Values are stored as integers, whose values are the number of days since 12/31/1899 01/01/01 to 12/31/9999.
DATETIMEThese are instances in time, including both the date and the time-of-day specifications.See Appendix J in your Informix 4gl Reference Manual.
INTERVALThese are signed durations of time measured in one or more of the same units as DATETIMESee Appendix J in your Informix 4gl Reference Manual.
SERIALThe Serial data type stores a sequential integer assigned automatically by the database server...
LIKE table.columnUse this to define a variable that is of the same type as table.columnIf the type of table.column is serial Informix assignes the type INTEGER.
RECORDThis data type describes a set of variable of possibly differing types, including other records...
ARRAY[i, j, k]This data type i x j x kvariable of the same data type.ARRAY variable can have from 1 to 3 dimensions..
' X PRINT '
' X PRINT ' ' X PRINT '' X END REPORT X X ##################################################### # This report simply creates a blank html page ##################################################### REPORT BlankPage() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT FIRST PAGE HEADER X PRINT '' X PRINT ' ' X ON LAST ROW X PRINT ' ' X PRINT '' X END REPORT X ##################################################### X FUNCTION BuildProcsPages() DEFINE sql_stmt CHAR(256) DEFINE TempStr CHAR(256) DEFINE Procedure RECORD LIKE SYSPROCEDURES.* DEFINE ProcBody CHAR(10000) DEFINE IdxName CHAR(256) DEFINE BodyName CHAR(256) DEFINE seqno INTEGER DEFINE procCount INTEGER X DISPLAY "Building Procedures Pages" X LET IdxName = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/ProcIndex.html" LET procCount = 0 X LET sql_stmt = "SELECT * ", X "FROM 'informix'.SYSPROCEDURES ", X "ORDER BY procid " X PREPARE proc_stmt FROM sql_stmt DECLARE proc_curs CURSOR WITH HOLD for proc_stmt X LET sql_stmt = "SELECT seqno, data ", X "FROM 'informix'.SYSPROCBODY ", X "WHERE procid = ? ", X "AND datakey = 'T' ", X "ORDER BY seqno " X X PREPARE body_stmt FROM sql_stmt DECLARE body_curs CURSOR FOR body_stmt X START REPORT ProcIndexRpt TO IdxName X FOREACH proc_curs INTO Procedure.* X LET procCount = procCount + 1 X INITIALIZE ProcBody TO NULL X OPEN body_curs USING Procedure.procid X FETCH body_curs INTO seqno, TempStr X X WHILE SQLCA.SQLCODE = 0 X LET ProcBody = ProcBody CLIPPED, TempStr CLIPPED X FETCH body_curs INTO seqno, TempStr X END WHILE X CLOSE body_curs X X LET BodyName = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Procedures/", Procedure.owner CLIPPED, Procedure.procname CLIPPED, ".html" X X START REPORT ProcBodyRpt TO BodyName X OUTPUT TO REPORT ProcBodyRpt(Procedure.*, ProcBody) X FINISH REPORT ProcBodyRpt X X OUTPUT TO REPORT ProcIndexRpt(Procedure.*) END FOREACH X FINISH REPORT ProcIndexRpt X IF procCount = 0 THEN X START REPORT BlankIndexes TO IdxName X OUTPUT TO REPORT BlankIndexes("Procedures") X FINISH REPORT BlankIndexes END IF X END FUNCTION X X ###################################################### REPORT DataBaseFrames() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '' END REPORT X ###################################################### REPORT DBNav() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '
Database : ',dbs[dbidx].name CLIPPED, '
PROCEDURES
TRIGGERS
VIEWS
TABLES
' X PRINT '
' X PRINT ' ' X PRINT '' END REPORT X ###################################################### REPORT ProcFrames() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '' X END REPORT X ###################################################### REPORT TrigFrames() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '' X END REPORT X ###################################################### REPORT ViewFrames() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '' X END REPORT X X ###################################################### REPORT TableFrames() X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '' X END REPORT X ##################################################### X REPORT ProcIndexRpt(Procedure) DEFINE Procedure RECORD LIKE SYSPROCEDURES.* X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT FIRST PAGE HEADER X PRINT '' X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X X ON LAST ROW X PRINT '
PROCNAME
OWNER
PROCID
MODE
PROC ARG COUNT
' X PRINT '
' X PRINT ' ' X PRINT '' X ON EVERY ROW X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ', Procedure.procname CLIPPED,'' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ', Procedure.owner CLIPPED X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '
', Procedure.procid USING "<<<<&", '
' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X IF Procedure.mode = "D" THEN X PRINT ' DBA' X ELSE X PRINT ' OWNER' X END IF X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '
', Procedure.numargs USING "<<<<&", '
' X PRINT '
' X PRINT ' ' X PRINT ' ' X END REPORT X ##################################################### X REPORT ProcBodyRpt(Procedure, Body) DEFINE Procedure RECORD LIKE SYSPROCEDURES.* DEFINE Body CHAR(10000) X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT X ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '
PROCEDURE NAME
PROCEDURE OWNER
PROCEDURE ID
', Procedure.procname CLIPPED, '', Procedure.owner CLIPPED, '', Procedure.procid CLIPPED, '
' X PRINT '
' X PRINT '
' X PRINT '
'
X  PRINT Body CLIPPED
X  PRINT '    
' X PRINT ' ' X PRINT '' X END REPORT X ##################################################### X FUNCTION BuildTrigsPages() DEFINE sql_stmt CHAR(256) DEFINE TempStr CHAR(256) DEFINE Trigger RECORD LIKE SYSTRIGGERS.* DEFINE EventType CHAR(18) DEFINE TrigBody CHAR(10000) DEFINE TrigAct CHAR(10000) DEFINE IdxName CHAR(256) DEFINE BodyName CHAR(256) DEFINE seqno INTEGER DEFINE tabOwner CHAR(8) DEFINE tabName CHAR(18) DEFINE trigCount INTEGER DEFINE datakey CHAR(1) X X LET IdxName = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/TrigIndex.html" DISPLAY "Building Triggers Pages " LET trigCount = 0 X LET sql_stmt = "SELECT * ", X "FROM 'informix'.SYSTRIGGERS ", X "ORDER BY trigid " X PREPARE trig_stmt FROM sql_stmt DECLARE trig_curs CURSOR WITH HOLD for trig_stmt X LET sql_stmt = "SELECT seqno, data ", X "FROM 'informix'.SYSTRIGBODY ", X "WHERE trigid = ? ", X "AND datakey = ? ", X "ORDER BY seqno " X PREPARE trig_body_stmt FROM sql_stmt DECLARE trig_body_curs CURSOR FOR trig_body_stmt X LET sql_stmt = "SELECT owner, tabname ", X "FROM 'informix'.SYSTABLES ", X "WHERE tabid = ?" X PREPARE tabid_stmt FROM sql_stmt DECLARE tabid_curs CURSOR FOR tabid_stmt X START REPORT TrigIndexRpt TO IdxName X FOREACH trig_curs INTO Trigger.* X LET trigCount = trigCount + 1 X LET datakey = "D" X X CASE Trigger.event X WHEN Trigger.event = "I" X LET EventType = "INSERT" X WHEN Trigger.event = "U" X LET EventType = "UPDATE" X WHEN Trigger.event = "D" X LET EventType = "DELETE" X OTHERWISE X LET EventType = "UNKNOWN" X END CASE X X OPEN tabid_curs USING Trigger.tabid X FETCH tabid_curs INTO tabOwner, tabName X CLOSE tabid_curs X X LET BodyName = curDir CLIPPED, dbs[dbidx].name CLIPPED, "/Triggers/", Trigger.owner CLIPPED, Trigger.trigname CLIPPED, ".html" X START REPORT TrigBodyRpt TO BodyName X X INITIALIZE TrigBody TO NULL X OPEN trig_body_curs USING Trigger.trigid, datakey X FETCH trig_body_curs INTO seqno, TempStr X X WHILE SQLCA.SQLCODE = 0 X LET TrigBody = TrigBody CLIPPED, TempStr CLIPPED X FETCH trig_body_curs INTO seqno, TempStr X END WHILE X CLOSE trig_body_curs X OUTPUT TO REPORT TrigBodyRpt(Trigger.*, TrigBody, tabOwner, tabName, datakey) X X LET datakey = "A" X INITIALIZE TrigBody TO NULL X OPEN trig_body_curs USING Trigger.trigid, datakey X FETCH trig_body_curs INTO seqno, TempStr X X WHILE SQLCA.SQLCODE = 0 X LET TrigBody = TrigBody CLIPPED, TempStr CLIPPED X FETCH trig_body_curs INTO seqno, TempStr X END WHILE X CLOSE trig_body_curs X OUTPUT TO REPORT TrigBodyRpt(Trigger.*, TrigBody, tabOwner, tabName, datakey) X X FINISH REPORT TrigBodyRpt X X OUTPUT TO REPORT TrigIndexRpt(Trigger.*, tabOwner, tabName) END FOREACH FINISH REPORT TrigIndexRpt X IF trigCount = 0 THEN X START REPORT BlankIndexes TO IdxName X OUTPUT TO REPORT BlankIndexes("Triggers") X FINISH REPORT BlankIndexes END IF END FUNCTION X X X ##################################################### X REPORT TrigIndexRpt(Trigger, tabOwner, tabName) DEFINE Trigger RECORD LIKE SYSTRIGGERS.* DEFINE tabOwner LIKE 'informix'.SYSTABLES.owner DEFINE tabName LIKE 'informix'.SYSTABLES.tabname DEFINE hTabname LIKE 'informix'.SYSTABLES.tabname X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT FIRST PAGE HEADER X PRINT '' X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X X ON LAST ROW X PRINT '
TRIGNAME
OWNER
TRIGID
TABLE
EVENT
OLD
NEW
MODE
' X PRINT '
' X PRINT ' ' X PRINT '' X ON EVERY ROW X PRINT ' ' X IF Trigger.old IS NULL X THEN X LET Trigger.old = '-' X END IF X IF Trigger.new IS NULL X THEN X LET Trigger.new = '-' X END IF X LET hTabname= UPSHIFT(tabName) X X PRINT ' ' X PRINT ' ' X PRINT ' ', Trigger.trigname CLIPPED,'' X PRINT ' ' X PRINT ' ' X X PRINT ' ' X PRINT ' ' X PRINT ' ', Trigger.owner CLIPPED X PRINT ' ' X PRINT ' ' X X PRINT ' ' X PRINT ' ' X PRINT '
', Trigger.trigid USING "<<<<&", '
' X PRINT '
' X PRINT ' ' X X PRINT ' ' X PRINT ' ' X PRINT '
' X PRINT ' ', tabName CLIPPED, '' X PRINT '
' X PRINT '
' X PRINT ' ' X X PRINT ' ' X PRINT ' ' X PRINT '
', Trigger.event, '
' X PRINT '
' X PRINT ' ' X X PRINT ' ' X PRINT ' ' X PRINT '
', Trigger.old , '
' X PRINT '
' X PRINT ' ' X X PRINT ' ' X PRINT ' ' X PRINT '
', Trigger.new , '
' X PRINT '
' X PRINT ' ' X X PRINT ' ' X PRINT ' ' X IF Trigger.mode = "D" THEN X PRINT ' DBA' X ELSE X PRINT ' OWNER' X END IF X PRINT ' ' X PRINT ' ' X PRINT ' ' X END REPORT X ##################################################### REPORT TrigBodyRpt(Trigger, Body, tabOwner, tabName, datakey) DEFINE Trigger RECORD LIKE SYSTRIGGERS.* DEFINE Body CHAR(10000) DEFINE tabOwner LIKE 'informix'.SYSTABLES.owner DEFINE tabName LIKE 'informix'.SYSTABLES.tabname DEFINE hTabName LIKE 'informix'.SYSTABLES.tabname DEFINE datakey CHAR(1) X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT FIRST PAGE HEADER X LET hTabName = UPSHIFT(tabName) X PRINT '' X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT '
TRIGGER NAME
TRIGGER OWNER
TRIGGER ID
TRIGGER TABLE
', Trigger.trigname CLIPPED, '
', Trigger.owner CLIPPED, '
', Trigger.trigid CLIPPED, '
' X PRINT ' "', tabOwner CLIPPED, '".', tabName CLIPPED X PRINT ' ' X PRINT '
' X PRINT '
' X ON EVERY ROW X PRINT '
' X IF datakey = "D" THEN X PRINT 'Trigger Header Definition:' X ELSE X PRINT 'Trigger Action Definition:' X END IF X PRINT '
' X PRINT '
'
X  PRINT Body CLIPPED
X  PRINT '    
' X ON LAST ROW X PRINT ' ' X PRINT '' X END REPORT X ###################################################### ###################################################### REPORT ViewIndexRpt(tabname, owner) DEFINE tabname LIKE systables.tabname DEFINE owner LIKE systables.owner X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT FIRST PAGE HEADER X PRINT '' X PRINT ' Views List' X PRINT ' ' X PRINT '
' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X ON EVERY ROW X PRINT ' ' X PRINT ' ' X PRINT ' ' X PRINT ' ' X ON LAST ROW X PRINT '
VIEW NAME
OWNER
', tabname CLIPPED, '',owner CLIPPED, '
' X PRINT '
' X PRINT ' ' X PRINT '' X END REPORT X ##################################################### REPORT theView(view_name, view_owner, theText) DEFINE view_name LIKE 'informix'.SYSTABLES.tabname DEFINE view_owner LIKE 'informix'.SYSTABLES.owner DEFINE theText CHAR(3000) X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT X ON EVERY ROW X PRINT '' X PRINT ' View Definition for :', view_name CLIPPED, '' X PRINT ' ' X PRINT '
View Name : ', view_name CLIPPED X PRINT '
View Owner: ', view_owner CLIPPED X PRINT '

' X PRINT theText CLIPPED X PRINT ' ' X PRINT '' X END REPORT X ##################################################### REPORT BlankIndexes(rptName) DEFINE rptName CHAR(18) X OUTPUT X TOP MARGIN 0 X BOTTOM MARGIN 0 X LEFT MARGIN 0 X PAGE LENGTH 100 X FORMAT X ON EVERY ROW X PRINT '' X PRINT ' ' X PRINT '
There were no ', rptName CLIPPED, ' Found.
' X PRINT ' ' X PRINT '' X END REPORT SHAR_EOF (set 20 02 09 20 08 09 29 'infmx2html.4gl'; eval "$shar_touch") && chmod 0644 'infmx2html.4gl' || $echo 'restore of' 'infmx2html.4gl' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'infmx2html.4gl:' 'MD5 check failed' ec4c93239ef0c8108791ea4d8a1d087e infmx2html.4gl SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'infmx2html.4gl'`" test 84979 -eq "$shar_count" || $echo 'infmx2html.4gl:' 'original size' '84979,' 'current size' "$shar_count!" fi fi rm -fr _sh05999 exit 0