Voyager : Query Basic

46
Voyager ReportingBasic SQL and a print monograph record 1 Voyager Reporting Basic SQL and a print monograph record Michael Cummings George Washington University Libraries January, 2014

Transcript of Voyager : Query Basic

Page 1: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 1

Voyager Reporting

Basic SQL and a print monograph record

Michael Cummings

George Washington University Libraries

January, 2014

Page 2: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 2

Table of ContentsIntroduction.................................................................................................................................................4

MARC 21 format bibliographic data........................................................................................................4

Voyager Catalog – Bibliographic record...................................................................................................5

MARC format holding data (“mfhd” or “muffhead”) record..................................................................6

MARC format holding data– ExLibris Voyager Catalog module view......................................................7

Bib, Holdings, and Items– ExLibris Voyager Catalog module view...........................................................8

Item record – ExLibris Voyager Circulation module view........................................................................9

ExLibris Voyager Acquisitions module view...........................................................................................10

Reports using SQL......................................................................................................................................11

SQL query bib_text table.......................................................................................................................12

Catalog information – bib_text table.....................................................................................................13

SQL query bib_index table.....................................................................................................................14

SQL query bib_ids of titles having a specific main author......................................................................15

SQL sort.................................................................................................................................................15

SQL query the bib_master table............................................................................................................16

Special function for handling Unicode in MS Access.............................................................................17

SQL query – a specific holding record...................................................................................................19

SQL query – location..............................................................................................................................20

SQL query - holding record(s) associated with a bib record..................................................................21

SQL query – a specific item record........................................................................................................22

SQL query – item barcode and item status............................................................................................23

SQL query – item(s) associated with a holding record...........................................................................23

SQL query – holding(s) and item(s) associated with a bib record..........................................................23

SQL query – specific purchase order by id.............................................................................................24

SQL Query – line items on a specific purchase order.............................................................................25

SQL Query – purchase order and line item matching a bib_id...............................................................26

SQL query – invoice line item price for a given bib_id...........................................................................27

SQL query – invoice line item and fund/ledger for a given bib_id.........................................................27

SQL query – price, fund, and ledger from an invoice for a specific bib_id.............................................28

Page 3: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 3

SQL Query summary profile of a bib_id print holding with one item....................................................29

Reference materials...............................................................................................................................30

[ blank page ]

Page 4: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 4

IntroductionThis document takes you through the Voyager system tables associated with a particular book,

“Philosophy : the quest for truth and meaning” which is owned by GWU. Some basic SQL query

statements will be explained here. The most important thing to know when you want to develop

reports from Voyager database is which tables and fields store the information you want. Let’s take a

look at our example, beginning with the machine readable catalog record (MARC 21).

MARC 21 format bibliographic data“Philosophy : the quest for truth and meaning”

01746cam a2200397 a 4500001000800000005001700008008004100025010001700066020001800083020001500101020002700116020002400143035002100167035002400188040004600212049000900258050002100267082001200288100002000300245006800320260005300388300002500441500003000466504005100496650003100547852001000578938004000588938005100628949001900679961002000698980004700718981001200765994001200777990037700789991018201166-7977843-20100412201423.0-091027s2010 mnu b 001 0 eng - a 2009045526- -a9780814654743- a0814654746- a9780814657270 (e-book)- a0814657273 (e-book)- a(OCoLC)457164785- a(OCoLC)ocn457164785- aDLCcDLCdBTCTAdYDXCPdC#PdBWXdOrLoB-B- aDGWW-00aBD21b.B325 2010-00a100222-1 aBeards, Andrew.-10aPhilosophy :bthe quest for truth and meaning /cAndrew Beards.- aCollegeville, Minn. :-bLiturgical Press,cc2010.- aix, 142 p. ;c23 cm.- a"A Michael Glazier book."- aIncludes bibliographical references and index.- 0aPhilosophyvIntroductions.- bgwg w- aYBP Library ServicesbYANKn3143509- aBlackwell Book ServicebBBUS-nR8835802c$16.95- b32882019588535- aNew title added- a2010-04-01b16.95-c.21e14.07f50124698g1- aAppv206- a92bDGW- 0gCh. 1.tWhat is this thing called "philosophy"? --gCh. 2.tThe process of coming to know --gCh. 3.tKnowing in common sense, science, history, and art --gCh. 4.tPositions on the theory of knowledge --gCh. 5.tMetaphysics : what philosophy can tell us about reality --gCh. 6.tA short introduction to ethics --gCh. 7.tPhilosophy of religion and the question of God.- aAndrew Beards is reader in philosophy and director of the distance-learning B.A. Philosophy and the Catholic Tradition program at Maryvale Institute, Birmingham, United Kingdom.-

MARC is a standard format that can be parsed by Integrated Library Systems like Voyager. There is a Python module, pymarc.py, which can read MARC data records. With certain VisualBasic modules for MS Access it is possible to read MARC data. ExLibris

provides the necessary VB modules in the MS Access database provided with Voyager. There are functions in Exlibris’ Voyager Oracle database that SQLPlus software can use to read

MARC data records. Other tools like ‘VGER Select’ from Northwestern University, and MARC-edit a free open source

software product can read MARC data records.

Page 5: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 5

Voyager Catalog – Bibliographic recordNext, let’s look at the same record in the Voyager Catalog module. Each title gets a system-generated id number. In this case, the bibliographic id is 7977843. This is the “bib_id.”

Page 6: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 6

Note: This sample record was intentionally selected in order to show how some vendors use tags

available for custom use (9xx tags). 1 The sample record was provided by the vendor YBP Library

Services as part of a pre-arranged book purchase approval plan. The record contains some fields that are

not usually present on our bibliographic records. It contains fields that represent not only the

bibliographic description, but also the associated item’s call number and barcode. The record also

contains some financial information. As a report writer you should be aware that you should only expect

bibliographic description fields on a bib record. In actual practice, the bibliographic record is just that, a

description of the main bibliographic record.

The bib record is the top-level record in a hierarchy of records;

o The bib records have one or more local holding records. The local holding record

contains the call number, and the link to an electronic resource, if any.

Each holding record may have one or more item records. Item records

describe a physical copy and information the physical item such as a

location, barcode, circulation data, and cost data.

MARC format holding data (“mfhd” or “muffhead”) record.

A bibliographic record may have zero or more local holding records. Most often, there is one holding. The holding record, like the bibliographic record is also a MARC data format.

00180nx a22000851 4500001000800000004000800008005001700016008003300033852002800066-9164061-7977843-20100412201426.0-1004120u||||8|||4001uu|||0000000-0 bgwg w-hBD21i.B325 2010-

1 For a complete list of MARC tags and their use, see http://www.loc.gov/marc/bibliographic/

Page 7: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 7

MARC format holding data– ExLibris Voyager Catalog module view

The Voyager system assigned a number to the holding, 9164061. This is how the Voyager system displays the MARC format holding data record:

The record is known as a ‘holding’ record, or as a “mfhd” or “muffhead” record.

The MARC bibliographic and holding information is stored in ExLibris Voyager as:

MARC data format

A set of relational database tables. Voyager uses an Oracle database.

The database records do not contain every tag found in the MARC records.

We will look at the database tables related to bibliographic and holding records. First, let’s complete the

big picture. The physical book is represented by an “Item” record.

Each holding may have zero or more items.

Items are used to record one or more copy of a holding.

Page 8: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 8

Bib, Holdings, and Items– ExLibris Voyager Catalog module view

This screenshot shows the three-level hierarchy of Voyager database records associated with the title “Philosophy : the quest for truth and meaning.”

o The bibliographic record (bib_id 7977843) is ‘owned’ by GW.

There is one holding of the book (mfhd_id 9164061).The holding location abbreviation is ‘gwg w’, and the call number is BD21 .B325 2010

There is one item liked to the holding. The item type is regular loan (item_id 5314835). The item status is currently not charged.

Page 9: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 9

Item record – ExLibris Voyager Circulation module view

Details about the item are stored in the Circulation module.

In this screenshot, you can see the item history tab. “Philosophy : the quest for truth and meaning” has not circulated (Historical Charges = 0). So much for approval plans – but that’s another story.

The item data is stored in relational database tables are associated with the catalog. Some Voyager database tables related to the item description are item, location, item_status, item_barcode, barcode.

Other Voyager database tables are associated with the Circulation functions such as transaction details to include patron information. Later we will look at some queries that list our item information.

Page 10: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 10

ExLibris Voyager Acquisitions module view

So far we covered the Catalog and Circulation modules. Financial information such as purchase orders, invoices, and funding is stored in relational database tables associated with the Acquisition function.

This screen shows

“Philosophy : the quest … meaning” was ordered via Purchase Order number 146339; One copy was purchased; it was paid on Invoice number 50124698

o the book was charged against the 2010 Approvals fund, on ledger gwgel2010103206.

More details are available by selecting the various tabs shown on the screen. Tables related to acquisitions include ledger, fund, fund_ledger_vw, purchase_order, invoice, invoice_line_item, invoice_line_item_funds, vendor

Page 11: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 11

Reports using SQL

If your workstation has an Oracle ODBC driver installed and your ExLibris reports.mdb Access

database has been linked the Voyager tables, you can copy the queries shown below. Paste a

query statement into the SQL view of the Access window where you create a new query. After

you paste the SQL statement into the window you may switch to the graphical user interface

view to see the tables, fields, and table joins associated with the SQL statement.

You may want to use the graphical user interface for your query development. It is a lot easier

than the SQL command interface.

The main thing for you to be familiar with is the set of tables that contain the data fields you

want to retrieve.

See the Reference section for a link to the data dictionary which lists all the Voyager tables.

Page 12: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 12

SQL query bib_text table

The two tables that contain almost all of the bib record data are named bib_text and bib_index.

An SQL query that generates the list of all fields from bib_text table for our sample title sends the result

to the file named item_bibtext is shown here. The “WHERE” statement matches on a specific bib_id

number. The bib_id field is the indexed (“key”) field; using the key field as selection criteria is very

efficient:

SELECT * INTO temp_bibtextFROM bib_textWHERE bib_text.bib_id='7977843';

Compare the content of bib_text table on the next page to the MARC record on page 1 of this

document. Notice that only the first ISBN listed on the MARC record is stored on the bib_text record.

The query above saves the results into a table. If the query does not include an INTO statement,

the results are just displayed on the screen. When query results are saved into a table, the table may be

exported. Another reason to save the results of the query into a table is that the new table may be

included in some other query.

Information for several records could be saved using a variation of the WHERE clause such as

the following:

WHERE bib_text.bib_id between ‘7977800’ and ‘7977900’

Page 13: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 13

Catalog information – bib_text table

BIB_ID AUTHOR TITLE TITLE_BRIEF UNIFORM_TITLE EDITION ISBN ISSN LCCN NETWORK_NUMBER SERIES CODEN GPONUM STDTECH OTHER_STD_NUM BEGIN_PUB_DATE END_PUB_DATE PUB_DATES_COMBINED PUBLISHER_DATE PUB_PLACE PUBLISHER PUBLISHER_NUMBER IMPRINT LANGUAGE BIB_FORMAT RECORD_STATUS ENCODING_LEVEL DESCRIP_FORM FIELD_008 PLACE_CODE DATE_TYPE_STATUS MAP_PROJECTION MAP_MATH_DATA

7977843Beards, Andrew.Philosophy : the quest for truth and meaning / Andrew Beards.Philosophy : the quest for truth and meaning /

9780814654743

2009045526(OCoLC)457164785

2010

2010c2010Collegeville, Minn. :Liturgical Press,

Collegeville, Minn. : Liturgical Press, c2010.engamc

a091027s2010 mnu b 001 0 engmnus

This table shows the results of the SQL query on the previous page.

Some of the data is abbreviated, such as language=’eng’ for English; bib_format=’am’ indicates this is a monograph. One instance of an ISBN, ISSN, LCCN, or NETWORK_NUMBER may be stored on a bib_text record. If there are multiples of these standard numbers on the MARC record, they’ll be recorded in the bib_index table.

** If you want to filter results using contents of the fields BIB_FORMAT, ISBN, ISSN, NETWORK_NUMBER, AUTHOR, etc., almost any bibliographic information you should have a WHERE statement. However, that statement should be based on the bib_index table, not the bib_text table. The bib_index table is described next.

Page 14: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 14

SQL query bib_index table

The table named bib_index stores the ISBN values (INDEX_CODE = 020A, 020N, or ISB3), and the subject (INDEX_CODE=6500) associated with the bib record. INDEX_CODE =010A is the LCCN. The DISPLAY_HEADING column shows the actual data, while the NORMAL_HEADING column contains the data converted for indexing.

The SQL query to report the results from bib_index is:

SELECT * INTO temp_bibindexFROM bib_indexWHERE bib_index.bib_id='7977843';

These are the query results:

BIB_ID INDEX_CODE NORMAL_HEADING DISPLAY_HEADING7977843 008D 2010 20107977843 008L eng eng7977843 008P mnu mnu7977843 010A 2009045526 20090455267977843 020A 9780814654743 97808146547437977843 020A 0814654746 08146547467977843 020A 9780814657270 E BOOK 9780814657270 (e-book)7977843 020A 0814657273 E BOOK 0814657273 (e-book)7977843 020N 9780814654743 97808146547437977843 020N 0814654746 08146547467977843 020N 9780814657270 9780814657270 (e-book)7977843 020N 0814657273 0814657273 (e-book)7977843 0350 OCOLC 457164785 (OCoLC)4571647857977843 035A 457164785 (OCoLC)4571647857977843 100H BEARDS ANDREW Beards, Andrew.7977843 2450 PHILOSOPHY THE QUEST FOR TRUTH

AND MEANINGPhilosophy : the quest for truth and meaning /

7977843 2451 PHILOSOPHY THE QUEST FOR TRUTH AND MEANING

Philosophy : the quest for truth and meaning /

7977843 2452 PHILOSOPHY THE QUEST FOR TRUTH AND MEANING

Philosophy : the quest for truth and meaning /

7977843 6500 PHILOSOPHY INTRODUCTIONS Philosophy Introductions.7977843 ISB3 9780814654743 97808146547437977843 ISB3 9780814657270 9780814657270 (e-book)

See the Reference section for a link to the data dictionary which lists all the possible index_codes.

Page 15: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 15

SQL query bib_ids of titles having a specific main author

Since we are looking at the bib_index table, here is a slight diversion from our title “Philosophy : the quest for truth and meaning”.

The field normal_heading of the bib_index table is indexed, as the name of the table might imply. You can use the normal_heading values as selection criteria in queries; the response should be very quick.

For example, a query to find all catalog records where Andrew Beards is the main author:

SELECT BIB_MASTER.LIBRARY_ID,BIB_INDEX.BIB_ID,TITLE_BRIEF INTO temp_bibindexFROM bib_master,bib_index,bib_textWHERE bib_index.index_code='100H'

ANDbib_index.normal_heading='BEARDS ANDREW'ANDbib_index.bib_id=bib_text.bib_idANDbib_master.bib_id=bib_index.bib_id;

LIBRARY_ID BIB_ID TITLE_BRIEF6 1973265 Philosophy : the quest for truth and meaning /6 2091304 Objectivity and historical understanding /14 5184857 Objectivity and historical understanding /14 7976876 Philosophy : the quest for truth and meaning /7 7977843 Philosophy : the quest for truth and meaning /6 7993294 Insight and analysis : essays in applying Lonergan's thought /3 8148140 Naming reference and metaphysics : Lonergan and analytical philosophy /2 8176057 Insight and analysis : essays in applying Lonergan's thought /5 11879205 Insight and Analysis13 12454778 Insight and analysis : essays in applying Lonergan's thought /

Some titles are listed more than once, because each consortium library has their own bib record, and the query has not filtered out records that are flagged ‘suppress from display in the catalog’, if any.

SQL sortThe results shown above could be sorted by title. To sort by title, add an “order by” statement to the end of the query:

Order by TITLE_BRIEF

The library_id, and suppressed flag are explained on the next page.

Page 16: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 16

SQL query the bib_master tableThe bib_master table identifies the id of the consortium library that owns the bib record, whether the record should be suppressed from the online public catalog, and when the record was created. Normally, a query should omit suppressed bib records.

BIB_ID 7977843LIBRARY_ID 7SUPPRESS_IN_OPAC NCREATE_DATE 4/12/2010 8:14:23 PM

Using an SQL statement Where BIB_MASTER.SUPPRESS_IN_OPAC=‘N’ will omit the suppressed bibs.The query that generated the table is

SELECT BIB_MASTER.BIB_ID, BIB_MASTER.LIBRARY_ID, BIB_MASTER.CREATE_DATE INTO temp_bibmasterFROM BIB_MASTERWHERE bib_master.suppress_in_opac=’N’ AND bib_master.bib_id='7977843';

List of values or ‘look up tables’

The library_id in the bib_master table above is a reference to a table named ‘library’ which contains other values. There are many tables that function as lists of values.

An SQL query needs to join the data table and list of value table by their common id in order to retrieve more descriptive fields from list of values table.

A query that gets the library name from the library table that matches on our sample bibliographic record in the bib_master table uses the common field named library_id

SELECT BIB_MASTER.BIB_ID, BIB_MASTER.LIBRARY_ID, BIB_MASTER.SUPPRESS_IN_OPAC, BIB_MASTER.CREATE_DATE,LIBRARY.LIBRARY_NAME INTO temp_bibmasterFROM BIB_MASTER, LIBRARYWHERE bib_master.bib_id='7977843'AND BIB_MASTER.LIBRARY_ID=LIBRARY.LIBRARY_ID;

BIB_ID 7977843LIBRARY_ID 7SUPPRESS_IN_OPAC NCREATE_DATE 4/12/2010 8:14:23 PMLIBRARY_NAME GW

Page 17: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 17

At this point three relational database tables that store the MARC bibliographic data and have the indexed key field “bib_id” in common have been identified.

bib_master bib_text bib_index

Two tables containing lists of values related to bibliographic data include

library bib_format

You can use the expression count(*) to find out how many records match the query.

Always use suppress_from_opac=’N’ to eliminate suppressed bib records from query results.

Example:

How many unsuppressed bib records are owned by GW? Approximately 1,736,000

Select count(*) as gwcounterfrom bib_master where library_id='7' AND suppress_in_opac='N';

Special function for handling Unicode in MS AccessThe Access database provided by ExLibris, reports.mdb, includes a function for handling Unicode characters / diacritics that may be in the fields title, title_brief, author, publisher, publish_date. The function UTF8to16 slightly improves the results.

Select title_brief from bib_text where bib_id='11491013';

Results show � characters where diacritics would displayAlex Katz, prints : catalogue raisonne��, 1947-2011 /

SELECT UTF8to16([TITLE_BRIEF]) AS uTITLE_BRIEFFROM bib_text WHERE bib_id='11491013';

Results show ? characters where diacritics would displayAlex Katz, prints : catalogue raisonne??, 1947-2011 /

Alternately, one can export the table of results, then do a search and replace command to replace � with nulls.

Page 18: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 18

SQL query – a specific holding record

Recall that the Voyager Catalog module provides a screen for the holding information. Voyager assigned the holding an id number, 9164061, to the holding for our sample title:

There is actually more data on the holding record than what one can see in the screenshot.

SELECT * INTO tbl_tempholdingFROM mfhd_masterWHERE mfhd_master.mfhd_id='9164061';

MFHD_ID 9164061LOCATION_ID 533CALL_NO_TYPE ONORMALIZED_CALL_NO BD 21 B 325 2010DISPLAY_CALL_NO BD21 .B325 2010SUPPRESS_IN_OPAC NSOURCE_MODULE CRECORD_STATUS nRECORD_TYPE xENCODING_LEVEL 1FIELD_007FIELD_008 1004120u||||8|||4001uu|||0000000CREATE_DATE 4/12/2010 8:14:26 PMetcetera

Page 19: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 19

SQL query – locationThe location_id references a list of values in the table named location.

The holding query can be modified to include the location name by joining the mfhd_master table and location table on their common field, location_id.

SELECT * INTO tbl_tempholdingFROM mfhd_master,locationWHERE mfhd_master.mfhd_id='9164061'and mfhd_master.location_id=location.location_id;

Or selected fields from the tables might be preferable. This query is one version, which uses Microsoft Access SQL syntax for joining the tables

SELECT mfhd_master.MFHD_ID, mfhd_master.NORMALIZED_CALL_NO, mfhd_master.SUPPRESS_IN_OPAC, mfhd_master.CREATE_DATE, location.LOCATION_ID, location.LOCATION_CODE, location.LOCATION_DISPLAY_NAME, location.LIBRARY_ID INTO tbl_tempholdingFROM mfhd_master INNER JOIN location ON mfhd_master.LOCATION_ID = location.LOCATION_IDWHERE mfhd_master.MFHD_ID=’9164061’;

An alternate version which does the same thing is

SELECT mfhd_master.MFHD_ID, mfhd_master.NORMALIZED_CALL_NO, mfhd_master.SUPPRESS_IN_OPAC, mfhd_master.CREATE_DATE, location.LOCATION_ID, location.LOCATION_CODE, location.LOCATION_DISPLAY_NAME, location.LIBRARY_ID INTO tbl_tempholdingFROM mfhd_master , locationWHERE mfhd_master.LOCATION_ID = location.LOCATION_IDAND mfhd_master.MFHD_ID=’9164061’;

MFHD_ID 9164061NORMALIZED_CALL_NO BD 21 B 325 2010SUPPRESS_IN_OPAC NCREATE_DATE 4/12/2010 8:14:26 PMLOCATION_ID 533LOCATON_CODE gwg wLOCATION_DISPLAY_NAME GW: GELMAN StacksLIBRARY_ID 7

Similar to the bibliographic record, a holding may be suppressed from the online public catalog. Usually one would omit suppressed holdings by adding WHERE mfhd_master.suppress_in_opac=’N’

Page 20: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 20

SQL query - holding record(s) associated with a bib record

In preceding pages we did an SQL query using the specific holding_id, 9164061.

In actual practice you usually don’t know in advance how many holding record(s) are associated with a bib record, nor their mfhd_id numbers. You may have noticed that unfortunately there is no bib_id on the holding record!

Voyager uses a table that is specifically designed to link data tables to each other (hence the name relational database). We need to add the table called bib_mfhd to our query in order to join the bib information and holding information. The bib_mfhd record has two fields, one pointing to the bib information and other pointing to the holding information.

In our example, “ Philosophy : the quest for truth and meaning “ the BIB_MFHD is shown below. It lists the bib_id and the mfhd_id.

SELECT * FROM BIB_MFHD WHERE BIB_ID='7977843';

BIB_ID MFHD_ID7977843 9164061

The query below links the BIB_TEXT table to the holding table using BIB_MFHD as the link:

SELECTBIB_TEXT.TITLE, MFHD_MASTER.LOCATION_ID, MFHD_MASTER.DISPLAY_CALL_NOFROM BIB_TEXT, BIB_MFHD, MFHD_MASTERWHEREBIB_TEXT.BIB_ID='7977843' AND BIB_TEXT.BIB_ID =BIB_MFHD.BIB_IDAND BIB_MFHD.MFHD_ID=MFHD_MASTER.MFHD_ID;

TITLE LOCATION_ID DISPLAY_CALL_NOPhilosophy : the quest for truth and meaning / Andrew Beards. 533 BD21 .B325 2010

The result above includes the title from the bib record along with the location id and call number from the holding associated with the bib record. The holding information was found using the connection to bib and holding which is recorded in a record the bib_mfhd table.

Page 21: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 21

SQL query – a specific item recordRecall that there is one holding and one item associated with our bib record. The Voyager catalog view showed this hierarchy:

Since we know the item_id, we could run a query against the item table to get some information:

Select ITEM_ID, PERM_LOCATION, TEMP_LOCATION2, ITEM_TYPE_ID, HISTORICAL_CHARGES FROM ITEM WHERE ITEM_ID='5314835';

ITEM_ID 5314835PERM_LOCATION 533TEMP_LOCATION 0ITEM_TYPE 3HISTORICAL_CHARGES 0

The description of the location and item_type can be retrieved from the list of value tables location and item_type. (This query was created using the graphical user interface in MS Access)

SELECT ITEM.ITEM_ID, ITEM.PERM_LOCATION, LOCATION.LOCATION_DISPLAY_NAME, ITEM.TEMP_LOCATION, ITEM.ITEM_TYPE_ID, ITEM_TYPE.ITEM_TYPE_DISPLAY, ITEM.HISTORICAL_CHARGESFROM (ITEM INNER JOIN ITEM_TYPE ON ITEM.ITEM_TYPE_ID = ITEM_TYPE.ITEM_TYPE_ID) INNER JOIN LOCATION ON ITEM.PERM_LOCATION = LOCATION.LOCATION_ID WHERE ITEM.ITEM_ID='5314835';

Adds two fields

LOCATON.LOCATION_DISPLAY_NAME GW: GELMAN Stacks

2 temp_location is used for temporary locations. Eg., the new book shelf

Page 22: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 22

ITEM_TYPE_DISPLAY Regular loan

SQL query – item barcode and item statusOptionally, an item may have notes or barcode(s). (This query was created using the graphical user interface in MS Access)

SELECT ITEM.ITEM_ID, ITEM_BARCODE.ITEM_BARCODE, ITEM_STATUS.ITEM_STATUS, ITEM_STATUS_TYPE.ITEM_STATUS_DESC, ITEM_STATUS.ITEM_STATUS_DATE, ITEM_NOTE.ITEM_NOTE, ITEM_NOTE.ITEM_NOTE_TYPEFROM (((ITEM LEFT JOIN ITEM_BARCODE ON ITEM.ITEM_ID = ITEM_BARCODE.ITEM_ID) LEFT JOIN ITEM_STATUS ON ITEM.ITEM_ID = ITEM_STATUS.ITEM_ID) LEFT JOIN ITEM_STATUS_TYPE ON ITEM_STATUS.ITEM_STATUS = ITEM_STATUS_TYPE.ITEM_STATUS_TYPE) LEFT JOIN ITEM_NOTE ON ITEM.ITEM_ID = ITEM_NOTE.ITEM_IDWHERE ITEM.ITEM_ID='5314835';

SQL query – item(s) associated with a holding recordIf the item_id is not known, the items associated with a holding may be retrieved with this query having the mfhd_id as selection criteria. (This query was created using the graphical user interface in MS Access)

SELECT MFHD_MASTER.MFHD_ID, MFHD_ITEM.ITEM_ID, ITEM.PERM_LOCATION, ITEM.TEMP_LOCATION, ITEM.COPY_NUMBER, ITEM.HISTORICAL_CHARGESFROM (MFHD_MASTER LEFT JOIN MFHD_ITEM ON MFHD_MASTER.MFHD_ID = MFHD_ITEM.MFHD_ID) LEFT JOIN ITEM ON MFHD_ITEM.ITEM_ID = ITEM.ITEM_IDWHERE MFHD_MASTER.MFHD_ID='9164061';

SQL query – holding(s) and item(s) associated with a bib record(This query was created using the graphical user interface in MS Access)

SELECT BIB_MASTER.BIB_ID, BIB_MASTER.LIBRARY_ID, MFHD_MASTER.MFHD_ID, MFHD_MASTER.LOCATION_ID, MFHD_MASTER.DISPLAY_CALL_NO, MFHD_ITEM.ITEM_ENUM, ITEM.PERM_LOCATION, ITEM.ITEM_TYPE_ID, BIB_TEXT.TITLE_BRIEFFROM BIB_TEXT INNER JOIN (((BIB_MASTER INNER JOIN BIB_MFHD ON BIB_MASTER.BIB_ID = BIB_MFHD.BIB_ID) INNER JOIN MFHD_MASTER ON BIB_MFHD.MFHD_ID = MFHD_MASTER.MFHD_ID) LEFT JOIN (ITEM RIGHT JOIN MFHD_ITEM ON ITEM.ITEM_ID = MFHD_ITEM.ITEM_ID) ON MFHD_MASTER.MFHD_ID = MFHD_ITEM.MFHD_ID) ON BIB_TEXT.BIB_ID = BIB_MASTER.BIB_IDWHERE BIB_MASTER.BIB_ID='7977843';

Page 23: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 23

The next section of this document will locate the financial data associated with the sample title. The tables in the Acquisitions module store this data. Recall that our book is shown in this screen shot from the Acquisitions module:

The Order refers to the purchase_order table. The purchase order may have many books. Each one is a “line item” on the purchase order (PO).

SQL query – specific purchase order by idSELECT PURCHASE_ORDER.PO_ID, PURCHASE_ORDER.VENDOR_ID, PURCHASE_ORDER.PO_TYPE, PURCHASE_ORDER.PO_STATUS, PURCHASE_ORDER.PO_STATUS_DATE, PURCHASE_ORDER.LINE_ITEM_COUNTFROM PURCHASE_ORDERWHERE PURCHASE_ORDER.PO_ID='146339';

Page 24: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 24

Results from the query for the order id:

PO_ID VENDOR_ID PO_TYPE PO_STAUS PO_STATUS_DATE LINE_ITEM_COUNT

146339 4929 0 4 4/14/2010 4:02:10 PM 11

The VENDOR_ID, PO_TYPE, and PO_STATUS fields are not very informative since they show the indexed numeric key for their associated list of values tables. The next query adds the descriptions from the list of value tables. (This query was created using the graphical user interface in MS Access)

SELECT PURCHASE_ORDER.PO_ID, PURCHASE_ORDER.VENDOR_ID, VENDOR.VENDOR_CODE, VENDOR.VENDOR_NAME, PURCHASE_ORDER.PO_TYPE, PO_TYPE.PO_TYPE_DESC, PURCHASE_ORDER.PO_STATUS, PO_STATUS.PO_STATUS_DESC, PURCHASE_ORDER.PO_STATUS_DATE, PURCHASE_ORDER.LINE_ITEM_COUNT, PO_CREATE_DATEFROM ((PURCHASE_ORDER INNER JOIN VENDOR ON PURCHASE_ORDER.VENDOR_ID = VENDOR.VENDOR_ID) INNER JOIN PO_TYPE ON PURCHASE_ORDER.PO_TYPE = PO_TYPE.PO_TYPE) INNER JOIN PO_STATUS ON PURCHASE_ORDER.PO_STATUS = PO_STATUS.PO_STATUSWHERE PURCHASE_ORDER.PO_ID='146339';

PO_ID 146339VENDOR_ID 4929VENDOR_CODE GWBBSAPVVENDOR_NAME Blackwell North America Inc - APVPO_TYPE 0PO_TYPE_DESC ApprovalPO_STATUS 4PO_STATUS_DESC Received CompletePO_STATUS_DATE 4/14/2010 4:02:10 PMLINE_ITEM_COUNT 11PO_CREATE_DATE 4/12/2010 8:14:14 PM

One can see that this was an approval order created 4/12/2010, having 11 items.Next, let’s find the specific line item associated with our Philosophy title, bib_id 7977843.

SQL Query – line items on a specific purchase orderSELECT PURCHASE_ORDER.PO_ID, LINE_ITEM.LINE_ITEM_NUMBER, LINE_ITEM.LINE_ITEM_ID, LINE_ITEM.LINE_PRICE, LINE_ITEM.BIB_IDFROM PURCHASE_ORDER INNER JOIN LINE_ITEM ON PURCHASE_ORDER.PO_ID = LINE_ITEM.PO_IDWHERE PURCHASE_ORDER.PO_ID='146339';

Page 25: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 25

Query resultsPO_ID LINE_ITEM_NUMBER LINE_ITEM_ID LINE_PRICE BIB_ID

146339 1 671125 8217 7977837146339 2 671126 8217 7977838146339 3 671127 4146 7977839146339 4 671128 2486 7977840146339 5 671129 1895 7977841146339 6 671130 2071 7977842146339 7 671131 1407 7977843146339 8 671132 3316 7977844146339 9 671133 2320 7977845146339 10 671134 4395 7977846146339 11 671135 2154 7977847

The query result above confirms there is a line item on this purchase order for the title having bib_id 7977843.

SQL Query – purchase order and line item matching a bib_idThe next query selects the bib_id 7977843 and converts the field LINE_PRICE 1407 into currency format.(Note: The field LINE_PRICE is assigned a different name than itself.)

SELECT PURCHASE_ORDER.PO_ID, LINE_ITEM.LINE_ITEM_ID, CCur([LINE_PRICE]/100) AS LPRICE, LINE_ITEM.BIB_IDFROM PURCHASE_ORDER INNER JOIN LINE_ITEM ON PURCHASE_ORDER.PO_ID = LINE_ITEM.PO_IDWHERE PURCHASE_ORDER.PO_ID='146339' AND LINE_ITEM.BIB_ID='7977843';

In fact, since the PO number is already on the line_item table, one wouldn’t necessarily need to join the line_item and purchase_order table unless fields from the PO need to be part of the results. This query check only the line_item table for a match on the bib_id.

SELECT LINE_ITEM.LINE_ITEM_ID, CCur([LINE_PRICE]/100) AS LPRICE, LINE_ITEM.BIB_IDFROM LINE_ITEMWHERE LINE_ITEM.BIB_ID='7977843';

LINE_ITEM_ID LPRICE BIB_ID671131 $14.07 7977843

The query result above shows that, according to the purchase order, the price of the item is $14.07 – however it is best to check the invoice for the price.

Page 26: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 26

SQL query – invoice line item price for a given bib_id

SELECT LINE_ITEM.LINE_ITEM_ID, CCur([LINE_ITEM.LINE_PRICE]/100) AS PO_PRICE, LINE_ITEM.BIB_ID, INVOICE_LINE_ITEM.INV_LINE_ITEM_ID, INVOICE_LINE_ITEM.INVOICE_ID, CCur([INVOICE_LINE_ITEM].[LINE_PRICE]/100) AS INVOICE_PRICEFROM LINE_ITEM INNER JOIN INVOICE_LINE_ITEM ON LINE_ITEM.LINE_ITEM_ID = INVOICE_LINE_ITEM.LINE_ITEM_IDWHERE LINE_ITEM.BIB_ID='7977843';

LINE_ITEM_ID 671131PO_PRICE $14.07BIB_ID 7977843INV_LINE_ITEM_ID 828252INVOICE_ID 138455INVOICE_PRICE $14.07

The query results indicate that the book was invoiced for the same amount as the purchase order price.The next logical step is to find out what funds were charged.

SQL query – invoice line item and fund/ledger for a given bib_idFor this query, the tables named fund and ledger could be used separately, however a convenient ‘view’ table, fund_ledger_vw, simplifies the number of joins that would be required. First, it is necessary to join the invoice line item to the linking table, invoice_line_item_funds.

SELECT LINE_ITEM.LINE_ITEM_ID, CCur([LINE_ITEM.LINE_PRICE]/100) AS PO_PRICE, LINE_ITEM.BIB_ID, INVOICE_LINE_ITEM.INV_LINE_ITEM_ID, INVOICE_LINE_ITEM.INVOICE_ID, CCur([INVOICE_LINE_ITEM].[LINE_PRICE]/100) AS INVOICE_PRICE, INVOICE_LINE_ITEM_FUNDS.LEDGER_ID, INVOICE_LINE_ITEM_FUNDS.FUND_IDFROM (LINE_ITEM INNER JOIN INVOICE_LINE_ITEM ON LINE_ITEM.LINE_ITEM_ID = INVOICE_LINE_ITEM.LINE_ITEM_ID) INNER JOIN INVOICE_LINE_ITEM_FUNDS ON INVOICE_LINE_ITEM.INV_LINE_ITEM_ID = INVOICE_LINE_ITEM_FUNDS.INV_LINE_ITEM_IDWHERE LINE_ITEM.BIB_ID='7977843';

Two fields are added. LEDGER_ID=335 and FUND_ID=13640Well, those are just ids – the details are in the fund ledger view. The next quey adds that table.

Page 27: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 27

SQL query – price, fund, and ledger from an invoice for a specific bib_id(This query was created using the graphical user interface in MS Access)

In this query, the fund name, ledger name, fiscal period name have been added. These fields are on the fund_ledger_vw table. The query joins the table by both fund_id and ledger_id . Several id numbers from the previous query are omitted in lieu of their descriptions

SELECT LINE_ITEM.BIB_ID, INVOICE_LINE_ITEM.INVOICE_ID, CCur([INVOICE_LINE_ITEM].[LINE_PRICE]/100) AS INVOICE_PRICE, FUNDLEDGER_VW.LEDGER_NAME, FUNDLEDGER_VW.FUND_NAME, FUNDLEDGER_VW.FISCAL_PERIOD_NAMEFROM ((LINE_ITEM INNER JOIN INVOICE_LINE_ITEM ON LINE_ITEM.LINE_ITEM_ID = INVOICE_LINE_ITEM.LINE_ITEM_ID) INNER JOIN INVOICE_LINE_ITEM_FUNDS ON INVOICE_LINE_ITEM.INV_LINE_ITEM_ID = INVOICE_LINE_ITEM_FUNDS.INV_LINE_ITEM_ID) INNER JOIN FUNDLEDGER_VW ON (INVOICE_LINE_ITEM_FUNDS.FUND_ID = FUNDLEDGER_VW.FUND_ID) AND (INVOICE_LINE_ITEM_FUNDS.LEDGER_ID = FUNDLEDGER_VW.LEDGER_ID)WHERE LINE_ITEM.BIB_ID='7977843';

BIB_ID 7977843INVOICE_ID 138455INVOICE_PRICE $14.07LEDGER_NAME gwgel2010103206FUND_NAME 10320658611ApprovalsFICAL_PERIOD_NAME GW 2009/2010

The last query on the next page will put all of the tables together to get a report on bib_id 7977843

NOTES

Because the query is for a bib_id we know has been invoiced and processed, no left joins were used in the query for simplicity. In actual practice, many left joins would be used to compensate for situations where the optional data isn’t present.

o For example if an item had not yet been barcoded, the whole query would return no result!

A full explanation of the tables associated with the Acquisitions module is outside the scope of this document.

Page 28: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 28

SQL Query summary profile of a bib_id print holding with one item(This query was created using the graphical user interface in MS Access)

SELECT BIB_TEXT.TITLE_BRIEF, BIB_TEXT.AUTHOR, BIB_TEXT.ISBN, LINE_ITEM.BIB_ID, LOCATION.LOCATION_DISPLAY_NAME, ITEM_BARCODE.ITEM_BARCODE, MFHD_MASTER.DISPLAY_CALL_NO, ITEM.HISTORICAL_CHARGES AS CHGHIST, ITEM_STATUS_TYPE.ITEM_STATUS_DESC, ITEM_TYPE.ITEM_TYPE_DISPLAY, CCur([INVOICE_LINE_ITEM].[LINE_PRICE]/100) AS INVOICE_PRICE, FUNDLEDGER_VW.LEDGER_NAME, FUNDLEDGER_VW.FUND_NAME, FUNDLEDGER_VW.FISCAL_PERIOD_NAMEFROM ((((((((((((LINE_ITEM INNER JOIN INVOICE_LINE_ITEM ON LINE_ITEM.LINE_ITEM_ID = INVOICE_LINE_ITEM.LINE_ITEM_ID) INNER JOIN INVOICE_LINE_ITEM_FUNDS ON INVOICE_LINE_ITEM.INV_LINE_ITEM_ID = INVOICE_LINE_ITEM_FUNDS.INV_LINE_ITEM_ID) INNER JOIN FUNDLEDGER_VW ON (INVOICE_LINE_ITEM_FUNDS.FUND_ID = FUNDLEDGER_VW.FUND_ID) AND (INVOICE_LINE_ITEM_FUNDS.LEDGER_ID = FUNDLEDGER_VW.LEDGER_ID)) INNER JOIN BIB_TEXT ON LINE_ITEM.BIB_ID = BIB_TEXT.BIB_ID) INNER JOIN BIB_ITEM ON BIB_TEXT.BIB_ID = BIB_ITEM.BIB_ID) INNER JOIN ITEM ON BIB_ITEM.ITEM_ID = ITEM.ITEM_ID) INNER JOIN ITEM_STATUS ON ITEM.ITEM_ID = ITEM_STATUS.ITEM_ID) INNER JOIN ITEM_TYPE ON ITEM.ITEM_TYPE_ID = ITEM_TYPE.ITEM_TYPE_ID) INNER JOIN LOCATION ON ITEM.PERM_LOCATION = LOCATION.LOCATION_ID) INNER JOIN ITEM_STATUS_TYPE ON ITEM_STATUS.ITEM_STATUS = ITEM_STATUS_TYPE.ITEM_STATUS_TYPE) INNER JOIN ITEM_BARCODE ON ITEM.ITEM_ID = ITEM_BARCODE.ITEM_ID) INNER JOIN BIB_MFHD ON (BIB_TEXT.BIB_ID = BIB_MFHD.BIB_ID) AND (BIB_TEXT.BIB_ID = BIB_MFHD.BIB_ID)) INNER JOIN MFHD_MASTER ON BIB_MFHD.MFHD_ID = MFHD_MASTER.MFHD_IDWHERE LINE_ITEM.BIB_ID='7977843';

TITLE_BRIEF Philosophy : the quest for truth and meaning /AUTHOR Beards, Andrew.ISBN 9780814654743BIB_ID 7977843LOCATION_DISPLAY_NAME GW: GELMAN StacksITEM_BARCODE 32882019588535DISPLAY_CALL_NO BD21 .B325 2010CHGHIST 0ITEM_STATUS_DESC Not ChargedITEM_TYPE_DISPLAY Regular loanINVOICE_PRICE $14.07LEDGER_NAME gwgel2010103206FUND_NAME 10320658611ApprovalsFISCAL_PERIOD_NAME GW 2009/2010

Page 29: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 29

Page 30: Voyager : Query Basic

Voyager Reporting Basic SQL and a print monograph record 30