From: mike Date: Mon, 5 Jun 2006 16:33:42 +0000 (+0000) Subject: Nice simple update client. X-Git-Tag: cpan_1_22~152 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=d849da1f31810a760c867a732405a7bffb2c6b88;p=ZOOM-Perl-moved-to-github.git Nice simple update client. --- diff --git a/samples/zoom/update.pl b/samples/zoom/update.pl new file mode 100755 index 0000000..c44cd20 --- /dev/null +++ b/samples/zoom/update.pl @@ -0,0 +1,135 @@ +#!/usr/bin/perl -w + +# $Id: update.pl,v 1.1 2006-06-05 16:33:42 mike Exp $ + +use strict; +use warnings; +use ZOOM; + +my $options = new ZOOM::Options(); +$options->option(user => "admin"); +$options->option(password => "fish"); +my $conn = create ZOOM::Connection($options); +$conn->connect("test.indexdata.com:2118"); +print "connected\n"; + +my $dbname = "mike$$"; +$conn->option(databaseName => $dbname); + +send_package($conn, "create", databaseName => $dbname); +print "$0: created database '$dbname'\n"; + +my $rs = $conn->search_pqf("mineral"); +my $n = $rs->size($rs); +print "$0: found $n records\n"; + +send_package($conn, "update", action => "specialUpdate", + recordIdOpaque => 1, record => join("", )); +print "$0: added record\n"; + +$rs = $conn->search_pqf("mineral"); +$n = $rs->size($rs); +print "$0: found $n records\n"; + +send_package($conn, "drop", databaseName => $dbname); +print "$0: deleted database\n"; + +eval { + $rs = $conn->search_pqf("mineral"); +}; if (!$@) { + print "$0: uh-oh\n"; +} elsif ($@->isa("ZOOM::Exception")) { + print "$0: database no longer there\n"; +} else { + die "@='$@'"; +} + + +sub send_package { + my($conn, $op, %options) = @_; + + my $p = $conn->package(); + foreach my $key (keys %options) { + $p->option($key, $options{$key}); + } + $p->send($op); + $p->destroy(); +} + + +__DATA__ + + + UTAH EARTHQUAKE EPICENTERS + <Acronym>UUCCSEIS</Acronym> + + UTAH GEOLOGICAL AND MINERAL SURVEY + + APPALACHIAN VALLEY; EARTHQUAKE; EPICENTER; SEISMOLOGY; UTAH + + + Five files of epicenter data arranged by date comprise this data + set. These files are searchable by magnitude and + longitude/latitude. Hardcopy of listing and plot of requested + area available. Epicenter location and date, magnitude, and focal + depth available. + DIGITAL DATA SETS + TERRESTRIAL + + Data are supplied by the University of Utah Seismograph + Station. The Utah Geologcial and Mineral Survey (UGMS) is merely + a clearinghouse of the data. + + + + US STATE + UTAH + + -114 + -109 + 42 + 37 + + + + -PRESENT + + + + UTAH GEOLOGICAL AND MINERAL SURVEY + 606 BLACK HAWK WAY + SALT LAKE CITY + UT + 84108 + USA + (801) 581-6831 + + UTAH EARTHQUAKE EPICENTERS + + AUTOMATED + BATCH + 8,700 + PC NETWORK + SALT LAKE CITY, UT + + + + NONE + + + OPERATIONAL + + + BILL CASE + UTAH GEOLOGICAL AND MINERAL SURVEY + 606 BLACK HAWK WAY + SALT LAKE CITY + UT + 84108 + USA + (801) 581-6831 + + ESDD0006 + UTAH GEOLOGICAL AND MINERAL SURVEY + 198903 +