Cross-platform Batch Reports Waldo Library Western Michigan University

advertisement
Cross-platform Batch Reports
Waldo Library
Western Michigan University
Objectives


show an implementation of automated,
cross-platform, hands-off report
generation in the Voyager environment
provide you with the information to do
this at your site
Bonus!!!!!
Source code for
BLOB access and
a table+column schema listing
included in the handout.
Brief Bio
Brief Bio

Working at WMU for 16 years now
Brief Bio


Working at WMU for 16 years now
Initially spent many years on the VAX
Brief Bio



Working at WMU for 16 years now
Initially spent many years on the VAX
Struggled for several years with the IBM
mainframe and NOTIS
Brief Bio




Working at WMU for 16 years now
Initially spent many years on the VAX
Struggled for several years with the IBM
mainframe and NOTIS
Supporting Voyager for close to 3 years
Brief Bio





Working at WMU for 16 years now
Initially spent many years on the VAX
Struggled for several years with the IBM
mainframe and NOTIS
Supporting Voyager for close to 3 years
Picked up some Oracle, (PL/)SQL, Perl,
and Unix along the way
Why We Did This
Why We Did This

initially no access to Access with ODBC
stuff; had no clue
Why We Did This


initially no access to Access with ODBC
stuff; had no clue
explored our Voyager Unix box, located
SQL*PLUS
Why We Did This





So we created reports run them on the Voyager box,
transfer to PC
format and print in Word,
etc...
Why We Did This



So we created reports library liked them I got tired of:
Why We Did This








So we created reports library liked them I got tired of:
running reports
ftping them
formatting them
printing them
physically delivering them
Unix
Cross-Platform Batch Reports
Overview of Process
(Handout page 4)
Unix
cron
Cross-Platform Batch Reports
Overview of Process
Unix
cron
Time/date
parameters
in one crontab
file
Cross-Platform Batch Reports
Overview of Process
Unix
cron
script
Time/date
parameters
in one crontab
file
Cross-Platform Batch Reports
Overview of Process
Unix
cron
script
SQL,
PL/SQL,
Perl
Time/date
parameters
in one crontab
file
Cross-Platform Batch Reports
Overview of Process
Unix
cron
Time/date
parameters
in one crontab
file
script
SQL,
PL/SQL,
Perl
report
One
cron process
running
Cross-Platform Batch Reports
Overview of Process
Unix
cron
Time/date
parameters
in one crontab
file
Cross-Platform Batch Reports
Overview of Process
script
SQL,
PL/SQL,
Perl
report
One
cron process
running
Batch PC
Unix
cron
Time/date
parameters
in one crontab
file
Cross-Platform Batch Reports
Overview of Process
script
SQL,
PL/SQL,
Perl
report
One
cron process
running
Batch PC
WinBatch
Unix
cron
Time/date
parameters
in one crontab
file
Cross-Platform Batch Reports
Overview of Process
script
SQL,
PL/SQL,
Perl
report
One
cron process
running
Batch PC
WinBatch
script or .exe
Unix
cron
Cross-Platform Batch Reports
Time/date
parameters
in one crontab
file
Overview of Process
script
SQL,
PL/SQL,
Perl
report
One
cron process
running
Batch PC
WinBatch
script or .exe
use ftp to
get the report
pull it
into Word
format
the report
Unix
Cross-Platform Batch Reports
Time/date
parameters
in one crontab
file
cron
Overview of Process
script
SQL,
PL/SQL,
Perl
One
cron process
running
report
Batch PC
WinBatch
script or .exe
use ftp to
get the report
pull it
into Word
format
the report
time/date parameters stored in each script
Unix
Cross-Platform Batch Reports
Time/date
parameters
in one crontab
file
cron
Overview of Process
script
SQL,
PL/SQL,
Perl
One
cron process
running
report
Batch PC
WinBatch
script or .exe
use ftp to
get the report
pull it
into Word
format
the report
time/date parameters stored in each script
copy report to
destination
on LAN
Unix
Cross-Platform Batch Reports
Time/date
parameters
in one crontab
file
cron
Overview of Process
script
SQL,
PL/SQL,
Perl
One
cron process
running
report
Batch PC
WinBatch
print report
to location
script or .exe
use ftp to
get the report
pull it
into Word
format
the report
time/date parameters stored in each script
copy report to
destination
on LAN
Unix
Cross-Platform Batch Reports
Time/date
parameters
in one crontab
file
cron
Overview of Process
script
SQL,
PL/SQL,
Perl
One
cron process
running
report
Batch PC
WinBatch
script or .exe
use ftp to
get the report
pull it
into Word
format
the report
time/date parameters stored in each script
print report
to location
Library Administration
Library Systems
Media Resources
Mono Acquisitions
Serials
copy report to
destination
on LAN
When to Choose SQL, PL/SQL,
or Perl

SQL
When to Choose SQL, PL/SQL,
or Perl


SQL
invoked from within SQL*PLUS
When to Choose SQL, PL/SQL,
or Perl



SQL
invoked from within SQL*PLUS
sufficient for most reports
When to Choose SQL, PL/SQL,
or Perl




SQL
invoked from within SQL*PLUS
sufficient for most reports
easy control of page & line size, page
formatting
When to Choose SQL, PL/SQL,
or Perl





SQL
invoked from within SQL*PLUS
sufficient for most reports
easy control of page & line size, page
formatting
takes control, does most of the work for
you
When to Choose SQL, PL/SQL,
or Perl






SQL
invoked from within SQL*PLUS
sufficient for most reports
easy control of page & line size, page
formatting
takes control, does most of the work for
you
output to screen or file
When to Choose SQL, PL/SQL,
or Perl



SQL
sample of code… (Handout page 5)
output snippet below
When to Choose SQL, PL/SQL,
identify what the report generates
or Perl
When to Choose SQL, PL/SQL,
or Perl include Word format settings
When to Choose SQL, PL/SQL,
or Perl
define output columns
When to Choose SQL, PL/SQL,
or Perl
these two columns are for sorting only
When to Choose SQL, PL/SQL,
or Perl
The call to FISCYRSETUP creates a temporary table, for the duration
of this report, that contains the name and start date for the current and
previous year. This is used in a number of reports to automatically
reference fiscal year data.
When to Choose SQL, PL/SQL,
or Perl
Set up title and some report parameters.
Want output in a file.
When to Choose SQL, PL/SQL,
or Perl
Run the query to
create the report.
Clean up when done.
When to Choose SQL, PL/SQL,
or Perl

PL/SQL
When to Choose SQL, PL/SQL,
or Perl


PL/SQL
invoked from within SQL*PLUS, or
embedded in / combined with SQL
When to Choose SQL, PL/SQL,
or Perl



PL/SQL
invoked from within SQL*PLUS, or
embedded in / combined with SQL
provides SQL capabilities with
programming language control added
When to Choose SQL, PL/SQL,
or Perl




PL/SQL
invoked from within SQL*PLUS, or
embedded in / combined with SQL
provides SQL capabilities with
programming language control added
functionality sort of in-between SQL and
Perl
When to Choose SQL, PL/SQL,
or Perl


PL/SQL
output to screen or to screen
When to Choose SQL, PL/SQL,
or Perl



PL/SQL
output to screen or to screen
Oracle allows output to file, but the
Voyager installation does not enable
this
When to Choose SQL, PL/SQL,
or Perl




PL/SQL
output to screen or to screen
Oracle allows output to file, but the
Voyager installation does not enable
this
size limited to 1 million bytes output
When to Choose SQL, PL/SQL,
or Perl





PL/SQL
output to screen or to screen
Oracle allows output to file, but the
Voyager installation does not enable
this
size limited to 1 million bytes output
screen output can be captured to file
When to Choose SQL, PL/SQL,
or Perl



PL/SQL
sample of code… (Handout pages 6 & 7)
output snippet below
When to Choose SQL, PL/SQL,
oroffPerl
start
with some comments…
output limitation…
When to Choose SQL, PL/SQL,
or Perl
important reminder
When to Choose SQL, PL/SQL,
or Perl
note the order by
When to Choose SQL, PL/SQL,
or Perl
variables must be declared
When to Choose
PL/SQL,
fields from theSQL,
table
or Perl
When to Choose SQL, PL/SQL,
or Perl you have control of looping through results
When to Choose SQL, PL/SQL,
It or
stands
for Binary Large Object. More simply put, it
Perl
is a collection of bytes that can contain both printable
What is a BLOB?
and unprintable characters. This is how MARC data
is stored under Voyager.
When to Choose SQL, PL/SQL,
The BLOB can be stored in one or more sections:
or Perl
BibID: 57 Seqnum: 1 Recseg: BLOB Part A
BibID: 57 Seqnum: 2 Recseg: BLOB Part B
When to Choose SQL, PL/SQL,
The BLOB can be stored in one or more sections:
or Perl
BibID: 57 Seqnum: 1 Recseg: BLOB Part A
BibID: 57 Seqnum: 2 Recseg: BLOB Part B
The BLOB is put together in
reverse order, because we can
depend on Seqnum #1 being
the last one that way.
When to Choose SQL, PL/SQL,
or Perl
get data from the header,
then get each tag’s data as we loop
through the directory structure
When to Choose SQL, PL/SQL,
or Perl
do some formatting...
When to Choose SQL, PL/SQL,
or Perl
print formatted tag data…
finish looping and end the program
When to Choose SQL, PL/SQL,
or Perl
Without the closing “/”,
your PL/SQL code
will NOT run!
When to Choose SQL, PL/SQL,
or Perl

Perl
When to Choose SQL, PL/SQL,
or Perl



Perl
invoked from the operating system
(can be called from within SQL(*PLUS)
When to Choose SQL, PL/SQL,
or Perl




Perl
invoked from the operating system
(can be called from within SQL(*PLUS)
you have control over everything, which
means:
When to Choose SQL, PL/SQL,
or Perl






Perl
invoked from the operating system
(can be called from within SQL(*PLUS)
you have control over everything, which
means:
relatively unlimited flexibility
that you have to do ALL the work
When to Choose SQL, PL/SQL,
or Perl







Perl
invoked from the operating system
(can be called from within SQL(*PLUS)
you have control over everything, which
means:
relatively unlimited flexibility
that you have to do ALL the work
output to screen or file
When to Choose SQL, PL/SQL,
or Perl



Perl
sample of code… (Handout pages 8 -10)
output snippet below
start off with some comments
When to Choose SQL, PL/SQL,
or Perl
When to Choose SQL, PL/SQL,
or Perl
You’ll need to have DBI and
DBD for Oracle set up on your Unix box.
When to Choose SQL, PL/SQL,
or Perl
set up some variables
When to Choose SQL, PL/SQL,
or Perl
need to be able to talk to the database
When to Choose SQL, PL/SQL,
or Perl
Get all the table names.
In my experience, I was unable to use the
reserved word “distinct” in the query.
Thus the extract code to dedupe the results.
When to Choose SQL, PL/SQL,
or Perl
need to know how many
columns per table to aid
in output formatting
When to Choose SQL, PL/SQL,
or Perl
set up and initiate output
When to Choose SQL, PL/SQL,
or Perl
get the report’s data
When to Choose SQL, PL/SQL,
or Perl
keep track of column names ending in “_id”
When to Choose
SQL,
PL/SQL,
go through array, output columns
or Perl
ending in “_id” first
When to Choose
SQL,
PL/SQL,
go through array, output columns
or Perl
ending in “_id” first
Remember counting columns per table?
Here we advance to the next page,
if the table doesn’t fit on the current page.
When to Choose
SQL,
PL/SQL,
then repeat this process for columns
that do not end in “_id”
or Perl
When to Choose
SQL,
if not enough
room for PL/SQL,
smallest
possible table, go to next page
or Perl
When to Choose SQL, PL/SQL,
or Perl
clean up when done
The Batch PC
The Batch PC

Should be dedicated to this task
The Batch PC


Should be dedicated to this task
configuration...
The Batch PC

Hardware
The Batch PC


Hardware
older pc will be adequate
The Batch PC



Hardware
older pc will be adequate
we’re using a 133MHz Pentium
The Batch PC




Hardware
older pc will be adequate
we’re using a 133MHz Pentium
32 meg RAM
The Batch PC





Hardware
older pc will be adequate
we’re using a 133MHz Pentium
32 meg RAM
1.5 gig hard disk, which is way more
than necessary
The Batch PC

Software
The Batch PC


Software
running Windows 95
The Batch PC




Software
running Windows 95
WinBatch software
(see www.windowware.com)
The Batch PC





Software
running Windows 95
WinBatch software
(see www.windowware.com)
the scripts that you write...
The Batch PC

The Batch Software
The Batch PC


The Batch Software
WinBatch installation will leave it
running in the background
The Batch PC



The Batch Software
WinBatch installation will leave it
running in the background
in Windows Explorer, double click on
your WinBatch script, identified as a
.WBT file
The Batch PC




The Batch Software
WinBatch installation will leave it
running in the background
in Windows Explorer, double click on
your WinBatch script, identified as a
.WBT file
it will either run right away, or appear on
the task bar, awaiting its time
Quick
Process
Review
Unix
Cross-Platform Batch Reports
Time/date
parameters
in one crontab
file
cron
Overview of Process
script
SQL,
PL/SQL,
Perl
One
cron process
running
report
Batch PC
WinBatch
script or .exe
use ftp to
get the report
pull it
into Word
format
the report
time/date parameters stored in each script
print report
to location
Library Administration
Library Systems
Media Resources
Mono Acquisitions
Serials
copy report to
destination
on LAN
The Batch PC


The Batch Software
FINALLY, a script!
(Handout pages 11 & 12)
The Batch PC
start off with comments,
including instructions on
when the script can be started safely
to avoid duplication of report printing
The Batch PC
set up paths and filenames on the Unix box
and the batch PC,
get the database password from a file
The Batch PC
determine if it’s time for the script to run
The Batch PC
Encapsulating the ftp process in a WinBatch
script file works well.
Use the DOS ftp program supplied with Windows.
The Batch PC
wait a minute for ftp to complete
make sure file exists, then launch Word with it
The Batch PC
send formatting keystrokes to Word
The Batch PC
the printer
pull-down menu,
The Get
Batch
PC
select the desired printer,
and print.
Wait a minute for printing to
complete before closing Word.
The Batch PC
The rest of the code closes loops and makes the script wait
until the next run time occurs.
Example from another script
illustrating how to trigger on
day of the week.
This script runs early in the morning,
six days a week.
The Batch PC


The Batch Software
Some final hints
The Batch PC



The Batch Software
Some final hints
WinBatch appears to get application
Windows confused, despite referring to
them by name in the scripts
The Batch PC




The Batch Software
Some final hints
WinBatch appears to get application
Windows confused, despite referring to
them by name in the scripts
set up trigger and run times so that they
do not overlap
The Batch PC






The Batch Software
Some final hints
long lines in your scripts:
don’t break them up!
WinBatch expects them to remain
contiguous!
Thanks for listening
Questions?
Email: zimmer@wmich.edu
Phone: 616.387.3885
Better Call Number Sorting
Roll your own!
What Voyager gives us…
We can achieve better results…
this is now our input
correctly sorted
Better Call Number Sorting

originally written in SAS back in our
NOTIS days
Better Call Number Sorting


originally written in SAS back in our
NOTIS days
ported to Perl for use with Voyager
Better Call Number Sorting



originally written in SAS back in our
NOTIS days
ported to Perl for use with Voyager
with NOTIS, could only sort on whole
call number field, with expected
atrocious results
Better Call Number Sorting




originally written in SAS back in our
NOTIS days
ported to Perl for use with Voyager
with NOTIS, could only sort on whole
call number field, with expected
atrocious results
Voyager provides normalized call
number, which allows for better than
80% correct sorting
Better Call Number Sorting



with intelligent parsing applied to the
call number, we can achieve about 99%
correct sorting
implemented it as a Perl module
put use Sort::CallNumber; at the
beginning of your Perl code
Better Call Number Sorting



one call returns the call number chunks:
@cnparts = cnparse($callnum);
then sort on the cnparts
Thanks for listening.
Contact me if you want to receive
the CallNumber Perl module.
Questions?
Email: zimmer@wmich.edu
Phone: 616.387.3885
Download