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

Ïîèñêîâûå ñëîâà: ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï ï
UPDATE OPUS
ShawíHong Kao
September 16, 1997
Usage
To generate opus N.sql output file, 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 file opus N.sql containing
insert/delete sql for use by OPUS.
Description/Algorithm
1. The tool first check input arguments, if user did not provide !p3? (delivery number),
the tool will use delivery number.value as default delivery number.
2. A script(output) file 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 fields in OPUS.
4. Write information message ''LOAD DATE USED=!current datetime?'' and
''DELIVERY NUMBER USED=!delivery number?'' 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 which contains cdbs table, fields name and corresponding opus table,
fields name by :
select !cdbs×field?, !cdbs×table?, !opus×field?
from opus×fields
where opus×table = !opus×table? and cdbs×table like ''!instrument?%''
to get field data type by :

select column×name = c.name, type = t.name
from dbo.syscolumns c, dbo.systypes t, dbo.sysobjects o
where o.name = !cdbs×table? and c.name = !cdbs×field?
and c.id = o.id and o.type = 'U' and c.usertype *= t.usertype
8. Based on the map array, create a string !sl? for the selectílist:
!map[0].cdbs×table×name?.!map[0].cdbs×field×name? s0,
!map[1].cdbs×table×name?.!map[1].cdbs×field×name? s1,
!map[2].cdbs×table×name?.!map[2].cdbs×field×name? s2, ...
and run query to get cdbs data:
select distinct !sl?
from !instrument?×file, !instrument?×row
where !instrument?×file.file×name = !instrument?×row.file×name
and !instrument?×file.file×name = !file×name?
and !instrument?×file.expansion×number = !instrument?×row.expansion×number
and !instrument?×file.expansion×number = !expansion×number?
9. If operation data (from item 5) = ''I'' then generate insert statement and write to output:
insert !opus×table? (map[i].opus×field..., load×time[, instrument])
values (map[i].field×value,..., @load×date[, ''!instrument×abbrev?'')
note: !instrument? data is for OPUS !caltable? table only
10. If operation data = ''R'' or ''D'' then generate a delete statement and write to output:
delete from !opus×table?
where map[i].opus×field = map[i].field×value ...
[and instrument = ''!instrument×abbrev?'']
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 file.
Files
There are two files for this tool, a source file write in C, using STDB interface to retrieve database
data, a make file 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 !server? íi update×opus×test.sql # the file is in test directory
$ update×opus !server? !dbname? [!delivery×number?] # 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 !server? íi !sql file?
example:
$ isql íS NOMAD íi opus×172.sql
3