c44cd2005d4e932ce3c40dc4490bc61bb5251ec6
[ZOOM-Perl-moved-to-github.git] / samples / zoom / update.pl
1 #!/usr/bin/perl -w
2
3 # $Id: update.pl,v 1.1 2006-06-05 16:33:42 mike Exp $
4
5 use strict;
6 use warnings;
7 use ZOOM;
8
9 my $options = new ZOOM::Options();
10 $options->option(user => "admin");
11 $options->option(password => "fish");
12 my $conn = create ZOOM::Connection($options);
13 $conn->connect("test.indexdata.com:2118");
14 print "connected\n";
15
16 my $dbname = "mike$$";
17 $conn->option(databaseName => $dbname);
18
19 send_package($conn, "create", databaseName => $dbname);
20 print "$0: created database '$dbname'\n";
21
22 my $rs = $conn->search_pqf("mineral");
23 my $n = $rs->size($rs);
24 print "$0: found $n records\n";
25
26 send_package($conn, "update", action => "specialUpdate",
27              recordIdOpaque => 1, record => join("", <DATA>));
28 print "$0: added record\n";
29
30 $rs = $conn->search_pqf("mineral");
31 $n = $rs->size($rs);
32 print "$0: found $n records\n";
33
34 send_package($conn, "drop", databaseName => $dbname);
35 print "$0: deleted database\n";
36
37 eval {
38     $rs = $conn->search_pqf("mineral");
39 }; if (!$@) {
40     print "$0: uh-oh\n";
41 } elsif ($@->isa("ZOOM::Exception")) {
42     print "$0: database no longer there\n";
43 } else {
44     die "@='$@'";
45 }
46
47
48 sub send_package {
49     my($conn, $op, %options) = @_;
50
51     my $p = $conn->package();
52     foreach my $key (keys %options) {
53         $p->option($key, $options{$key});
54     }
55     $p->send($op);
56     $p->destroy();
57 }
58
59
60 __DATA__
61 <gils>
62   <Title>
63     UTAH EARTHQUAKE EPICENTERS
64     <Acronym>UUCCSEIS</Acronym>
65   </Title>
66   <Originator>UTAH GEOLOGICAL AND MINERAL SURVEY</Originator>
67   <Local-Subject-Index>
68     APPALACHIAN VALLEY; EARTHQUAKE; EPICENTER; SEISMOLOGY; UTAH
69   </Local-Subject-Index>
70   <Abstract>
71     Five files of epicenter data arranged by date comprise this data
72     set.  These files are searchable by magnitude and
73     longitude/latitude.  Hardcopy of listing and plot of requested
74     area available.  Epicenter location and date, magnitude, and focal
75     depth available.
76     <Format>DIGITAL DATA SETS</Format>
77     <Data-Category>TERRESTRIAL</Data-Category>
78     <Comments>
79       Data are supplied by the University of Utah Seismograph
80       Station. The Utah Geologcial and Mineral Survey (UGMS) is merely
81       a clearinghouse of the data.
82     </Comments>
83   </Abstract>
84   <Spatial-Domain>
85     <Geographic-Coverage>US STATE</Geographic-Coverage>
86     <Coverage-Description>UTAH</Coverage-Description>
87     <Bounding-Coordinates>
88       <West-Bounding-Coordinate>-114</West-Bounding-Coordinate>
89       <East-Bounding-Coordinate>-109</East-Bounding-Coordinate>
90       <North-Bounding-Coordinate>42</North-Bounding-Coordinate>
91       <South-Bounding-Coordinate>37</South-Bounding-Coordinate>
92     </Bounding-Coordinates>
93   </Spatial-Domain>
94   <Time-Period>
95     <Time-Period-Textual>-PRESENT</Time-Period-Textual>
96   </Time-Period>
97   <Availability>
98     <Distributor>
99       <Organization>UTAH GEOLOGICAL AND MINERAL SURVEY</Organization>
100       <Street-Address>606 BLACK HAWK WAY</Street-Address>
101       <City>SALT LAKE CITY</City>
102       <State>UT</State>
103       <Zip-Code>84108</Zip-Code>
104       <Country>USA</Country>
105       <Telephone>(801) 581-6831</Telephone>
106     </Distributor>
107     <Resource-Description>UTAH EARTHQUAKE EPICENTERS</Resource-Description>
108     <Technical-Prerequisites>
109       <Data-Set-Type>AUTOMATED</Data-Set-Type>
110       <Access-Method>BATCH</Access-Method>
111       <Number-of-Records>8,700</Number-of-Records>
112       <Computer-Type>PC NETWORK</Computer-Type>
113       <Computer-Location>SALT LAKE CITY, UT</Computer-Location>
114     </Technical-Prerequisites>
115   </Availability>
116   <Access-Constraints>
117     <Documentation>NONE</Documentation>
118   </Access-Constraints>
119   <Use-Constraints>
120     <Status>OPERATIONAL</Status>
121   </Use-Constraints>
122   <Point-of-Contact>
123     <Name>BILL CASE</Name>
124     <Organization>UTAH GEOLOGICAL AND MINERAL SURVEY</Organization>
125     <Street-Address>606 BLACK HAWK WAY</Street-Address>
126     <City>SALT LAKE CITY</City>
127     <State>UT</State>
128     <Zip-Code>84108</Zip-Code>
129     <Country>USA</Country>
130     <Telephone>(801) 581-6831</Telephone>
131   </Point-of-Contact>
132   <Control-Identifier>ESDD0006</Control-Identifier>
133   <Record-Source>UTAH GEOLOGICAL AND MINERAL SURVEY</Record-Source>
134   <Date-of-Last-Modification>198903</Date-of-Last-Modification>
135 </gils>