Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://www.stsci.edu/instruments/observatory/cdbs/image/comments_sql_gen.ps
Äàòà èçìåíåíèÿ: Tue Sep 16 18:41:13 1997
Äàòà èíäåêñèðîâàíèÿ: Sun Mar 2 09:13:39 2014
Êîäèðîâêà:

Ïîèñêîâûå ñëîâà: arp 220
comments sql gen
Rick Whitman
November 27, 1996
Usage
The tool is invoked by entering comments sql gen on the command line followed
by one argument which is a file specification for the updated load file you want
to process. For example:
comments—sql—gen a3d1145dy.lod
The input load file will generally have been created using the recreate load file
command which recreates a load file based on the database contents for a par­
ticular reference file. The load file can then be edited to update the comments.
No other keywords in the load file should be changed. Changing any of the
mode keywords will invalidate the SQL that is produced by this tool.
There are also two environment variables that must be defined in order for the
tool to perform some database actions using OpenSTDB. These environment
variables are:
ffl CDBS SERVER ­ set to the database server name (in uppercase)
ffl CDBS DB ­ set to the CDBS database name (in lowercase)
The output will be a single SQL file which, when executed will update the
appropriate database tables with the new comments contained in the load file.
The file will be named comments delivery!number?.sql where !number? will
be the delivery number found in current version of the file­level relation in the
database. For example:
comments—delivery123.sql
The tool will also output a line indicating the input file currently being
processed to stdout.
Processing a3d1145dy.lod ...
It will also write messages indicating errors, if they occur, to stdout. Upon
detection of an error the task is terminated.

Algorithm/Module Description
The tool consists of a single file with several functions. It also calls functions
from the loadutils library, the loadfile library and the OpenSTDB library. For
each load file, the following steps occur:
ffl The load file is read into an internal structure using the read loadfile func­
tion from the loadfile library. This allows for the load file data to subse­
quently be referenced using the loadfile library functions.
ffl Next, SQL is generated to update the file­level and row­level relations in
the database based on the file name and mode keywords in the load file.
Note that for expanded load files, each of the file­level records associated
with the reference file will be updated with the single comment in the load
file header section.
The row­level SQL is as follows:
update !instrument?—row set comment = !comment?
where file—name = !file—name?
and mode—keyword1 = !mode—keyword1?
and mode—keyword2 = !mode—keyword2?
...
and mode—keywordN = !mode—keywordN?
The file­level SQL is as follows:
update !instrument?—file set comment = !comment?
where file—name = !file—name?
The !file name? is read from the header of the load file and the !mode keyword?
values are read from the rows of the detailed section of the load file. The file­
level comment and row level comments are read from the header and the detailed
sections respectively
Testing
The test script comments sql gen.sh is available to test the comments sql gen
tool. The test script is invoked by entering its name. It is assumed that you are
running the script from the cdbs/test/script directory and that your data is in
the cdbs/test/data directory and that a cdbs/test/data/tmp directory exists.
The script uses following files:
2

ffl unex­hrs­init.lod ­ this file is an example of an initial unexpanded load
file.
ffl unex­hrs­new.lod ­ this is the same load file as above but with the com­
ments updated.
ffl ex­hrs­init.lod ­ this file is an example of an initial expanded load file.
ffl ex­hrs­new.lod ­ this is the same load file as above but with the comments
updated.
Note that these files are not intended to be accurate examples of CDBS load
files but are only intended to demonstrate the various program paths.
The following steps will take place during the test:
ffl cdbs sql gen will be run on unex­hrs­init.lod which will create the file
cdbs delivery301.sql. The sql file will be executed to load the values into
the database.
ffl The database will be queried to get the comments associated with the
reference file loaded by unex­hrs­init.lod. The results of the query will be
saved in unex­init.dat
ffl comments sql gen will be run on unex­hrs­new.lod which will create the
file comments delivery301.sql. The sql file will be executed to load the
values into the database.
ffl The database will be queried to get the comments associated with the
reference file loaded by unex­hrs­new.lod. The results of the query will be
saved in unex­new.dat
ffl cdbs sql gen will be run on ex­hrs­init.lod which will create the file cdbs delivery302.sql.
The sql file will be executed to load the values into the database.
ffl The database will be queried to get the comments associated with the
reference file loaded by ex­hrs­init.lod. The results of the query will be
saved in unex­init.dat
ffl comments sql gen will be run on ex­hrs­new.lod which will create the file
comments delivery302.sql. The sql file will be executed to load the values
into the database.
ffl The database will be queried to get the comments associated with the
reference file loaded by ex­hrs­new.lod. The results of the query will be
saved in ex­new.dat
ffl unex­init.dat will be differenced against unex­new.dat and ex­init.dat will
be differenced against ex­new.dat to show that the comments have been
updated in the database
3