Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/hst/observatory/crds/documents/update_opus.pdf
Дата изменения: Unknown
Дата индексирования: Sun Mar 2 06:42:51 2014
Кодировка:
UPDATE OPUS
Shaw-Hong Kao September 16, 1997

Usage
To generate opus N.sql output le, at command line, type :
$ update_opus p1 p2 p3] where p1 = server name p2 = database name p3 = delivery number, if ommit, use default delivery_number.value

Purpose
The tool retrieve CDBS database's OPUS data and generate a script le opus N.sql containing insert/delete sql for use by OPUS.

Description/Algorithm
1. The tool rst check input arguments, if user did not provide (delivery number), the tool will use delivery number.value as default delivery number. 2. A script(output) le will be create, start with "begin transcation". 3. Create local variable @load date to save current time "dd-MMM-yyyy hh:mm:ss" for use by load time elds in OPUS. 4. Write information message "LOAD DATE USED=" and "DELIVERY NUMBER USED=" to output. 5. Loop through opus log table to get file name, expansion number, instrument, reference file type, operation data having delivery number = delivery number 6. Get opus table name from relation info table having instrument, reference file type equals to the data retrieved from item 5. 7. Create map record array whichcontains cdbs table, elds name and corresponding opus table, elds name by:
select , , from opus_fields where opus_table = and cdbs_table like "%"

to get eld data type by:


select from where and

column_name = c.name, type = t.name dbo.syscolumns c, dbo.systypes t, dbo.sysobjects o o.name = and c.name = c.id = o.id and o.type = 'U' and c.usertype *= t.usertype

8. Based on the map array, create a string for the select-list:
. s0, . s1, . s2, ...

and run query to get cdbs data:
select from where and and and distinct _file, _row _file.file_name = _row.file_name _file.file_name = _file.expansion_number = _row.expansion_number _file.expansion_number =

9. If

operation

data (from item 5) = "I" then generate insert statement and write to output:

insert (map i].opus_field..., load_time , instrument]) values (map i].field_value,..., @load_date , "")

note: data is for OPUS table only 10. If operation data = "R" or "D" then generate a delete statement and write to output:
delete from where map i].opus_field = map i].field_value ... and instrument = ""]

11. Go back to item 5) until no more record returned from opus log table. 12. Write information message "OPUS MODS OK" and "commit transaction" to output and close database connection and output le.

Files
There are two les for this tool, a source le write in C, using STDB interface to retrieve database data, a make le to generate executable:
update_opus.c -- source code Makefile

2


Testing
$ # use default CDBS db account and default database to load test data to $ # CDBS database $ isql -S -i update_opus_test.sql # the file is in test directory $ update_opus ] # src/update_opus directory example: $ update_opus ROBBIE cdbs_dev 172 ! will create opus_172.sql $ update_opus ROBBIE cdbs_dev ! create opus_174.sql ! since 174 is the latest delivery number

Load SQL File
$ # use default OPUS db account and default OPUS database $ isql -S -i example: $ isql -S NOMAD -i opus_172.sql

3