Batchhow

434 views

Published on

Cross-Platform Batch reports using WinBatch
presented at VUGM 2001

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
434
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Batchhow

  1. 1. Cross-platform Batch Reports Waldo Library Western Michigan University
  2. 2. Objectives <ul><li>show an implementation of automated, cross-platform, hands-off report generation in the Voyager environment </li></ul><ul><li>provide you with the information to do this at your site </li></ul>
  3. 3. Bonus!!!!! Source code for BLOB access and a table+column schema listing included in the handout.
  4. 4. Brief Bio
  5. 5. Brief Bio <ul><li>Working at WMU for 16 years now </li></ul>
  6. 6. Brief Bio <ul><li>Working at WMU for 16 years now </li></ul><ul><li>Initially spent many years on the VAX </li></ul>
  7. 7. Brief Bio <ul><li>Working at WMU for 16 years now </li></ul><ul><li>Initially spent many years on the VAX </li></ul><ul><li>Struggled for several years with the IBM mainframe and NOTIS </li></ul>
  8. 8. Brief Bio <ul><li>Working at WMU for 16 years now </li></ul><ul><li>Initially spent many years on the VAX </li></ul><ul><li>Struggled for several years with the IBM mainframe and NOTIS </li></ul><ul><li>Supporting Voyager for close to 3 years </li></ul>
  9. 9. Brief Bio <ul><li>Working at WMU for 16 years now </li></ul><ul><li>Initially spent many years on the VAX </li></ul><ul><li>Struggled for several years with the IBM mainframe and NOTIS </li></ul><ul><li>Supporting Voyager for close to 3 years </li></ul><ul><li>Picked up some Oracle, (PL/)SQL, Perl, and Unix along the way </li></ul>
  10. 10. Why We Did This
  11. 11. Why We Did This <ul><li>initially no access to Access with ODBC stuff; had no clue </li></ul>
  12. 12. Why We Did This <ul><li>initially no access to Access with ODBC stuff; had no clue </li></ul><ul><li>explored our Voyager Unix box, located SQL*PLUS </li></ul>
  13. 13. Why We Did This <ul><li>So we created reports - </li></ul><ul><li>run them on the Voyager box, </li></ul><ul><li>transfer to PC </li></ul><ul><li>format and print in Word, </li></ul><ul><li>etc... </li></ul>
  14. 14. Why We Did This <ul><li>So we created reports - </li></ul><ul><li>library liked them - </li></ul><ul><li>I got tired of: </li></ul>
  15. 15. Why We Did This <ul><li>So we created reports - </li></ul><ul><li>library liked them - </li></ul><ul><li>I got tired of: </li></ul><ul><li>running reports </li></ul><ul><li>ftping them </li></ul><ul><li>formatting them </li></ul><ul><li>printing them </li></ul><ul><li>physically delivering them </li></ul>
  16. 16. Cross-Platform Batch Reports Overview of Process (Handout page 4) Unix
  17. 17. cron Cross-Platform Batch Reports Overview of Process Unix
  18. 18. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file
  19. 19. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file script
  20. 20. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file script SQL, PL/SQL, Perl
  21. 21. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file script SQL, PL/SQL, Perl report One cron process running
  22. 22. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file script SQL, PL/SQL, Perl report One cron process running Batch PC
  23. 23. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file script SQL, PL/SQL, Perl report One cron process running Batch PC WinBatch
  24. 24. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file script SQL, PL/SQL, Perl report One cron process running Batch PC WinBatch script or .exe
  25. 25. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file 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
  26. 26. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file 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 time/date parameters stored in each script
  27. 27. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file 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 time/date parameters stored in each script copy report to destination on LAN
  28. 28. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file 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 time/date parameters stored in each script copy report to destination on LAN print report to location
  29. 29. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file 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 time/date parameters stored in each script copy report to destination on LAN print report to location Library Administration Library Systems Media Resources Mono Acquisitions Serials
  30. 30. When to Choose SQL, PL/SQL, or Perl <ul><li>SQL </li></ul>
  31. 31. When to Choose SQL, PL/SQL, or Perl <ul><li>SQL </li></ul><ul><li>invoked from within SQL*PLUS </li></ul>
  32. 32. When to Choose SQL, PL/SQL, or Perl <ul><li>SQL </li></ul><ul><li>invoked from within SQL*PLUS </li></ul><ul><li>sufficient for most reports </li></ul>
  33. 33. When to Choose SQL, PL/SQL, or Perl <ul><li>SQL </li></ul><ul><li>invoked from within SQL*PLUS </li></ul><ul><li>sufficient for most reports </li></ul><ul><li>easy control of page & line size, page formatting </li></ul>
  34. 34. When to Choose SQL, PL/SQL, or Perl <ul><li>SQL </li></ul><ul><li>invoked from within SQL*PLUS </li></ul><ul><li>sufficient for most reports </li></ul><ul><li>easy control of page & line size, page formatting </li></ul><ul><li>takes control, does most of the work for you </li></ul>
  35. 35. When to Choose SQL, PL/SQL, or Perl <ul><li>SQL </li></ul><ul><li>invoked from within SQL*PLUS </li></ul><ul><li>sufficient for most reports </li></ul><ul><li>easy control of page & line size, page formatting </li></ul><ul><li>takes control, does most of the work for you </li></ul><ul><li>output to screen or file </li></ul>
  36. 36. When to Choose SQL, PL/SQL, or Perl <ul><li>SQL </li></ul><ul><li>sample of code… (Handout page 5) </li></ul><ul><li>output snippet below </li></ul>
  37. 37. When to Choose SQL, PL/SQL, or Perl identify what the report generates
  38. 38. When to Choose SQL, PL/SQL, or Perl include Word format settings
  39. 39. When to Choose SQL, PL/SQL, or Perl define output columns
  40. 40. When to Choose SQL, PL/SQL, or Perl these two columns are for sorting only
  41. 41. 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.
  42. 42. When to Choose SQL, PL/SQL, or Perl Set up title and some report parameters. Want output in a file.
  43. 43. When to Choose SQL, PL/SQL, or Perl Run the query to create the report. Clean up when done.
  44. 44. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul>
  45. 45. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>invoked from within SQL*PLUS, or embedded in / combined with SQL </li></ul>
  46. 46. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>invoked from within SQL*PLUS, or embedded in / combined with SQL </li></ul><ul><li>provides SQL capabilities with programming language control added </li></ul>
  47. 47. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>invoked from within SQL*PLUS, or embedded in / combined with SQL </li></ul><ul><li>provides SQL capabilities with programming language control added </li></ul><ul><li>functionality sort of in-between SQL and Perl </li></ul>
  48. 48. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>output to screen or to screen </li></ul>
  49. 49. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>output to screen or to screen </li></ul><ul><li>Oracle allows output to file, but the Voyager installation does not enable this </li></ul>
  50. 50. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>output to screen or to screen </li></ul><ul><li>Oracle allows output to file, but the Voyager installation does not enable this </li></ul><ul><li>size limited to 1 million bytes output </li></ul>
  51. 51. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>output to screen or to screen </li></ul><ul><li>Oracle allows output to file, but the Voyager installation does not enable this </li></ul><ul><li>size limited to 1 million bytes output </li></ul><ul><li>screen output can be captured to file </li></ul>
  52. 52. When to Choose SQL, PL/SQL, or Perl <ul><li>PL/SQL </li></ul><ul><li>sample of code… (Handout pages 6 & 7) </li></ul><ul><li>output snippet below </li></ul>
  53. 53. When to Choose SQL, PL/SQL, or Perl start off with some comments… output limitation…
  54. 54. When to Choose SQL, PL/SQL, or Perl important reminder
  55. 55. When to Choose SQL, PL/SQL, or Perl note the order by
  56. 56. When to Choose SQL, PL/SQL, or Perl variables must be declared
  57. 57. When to Choose SQL, PL/SQL, or Perl fields from the table
  58. 58. When to Choose SQL, PL/SQL, or Perl you have control of looping through results
  59. 59. When to Choose SQL, PL/SQL, or Perl What is a BLOB ? It stands for B inary L arge Ob ject. More simply put, it is a collection of bytes that can contain both printable and unprintable characters. This is how MARC data is stored under Voyager.
  60. 60. When to Choose SQL, PL/SQL, or Perl The BLOB can be stored in one or more sections: BibID: 57 Seqnum: 1 Recseg: BLOB Part A BibID: 57 Seqnum: 2 Recseg: BLOB Part B
  61. 61. When to Choose SQL, PL/SQL, or Perl The BLOB can be stored in one or more sections: 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.
  62. 62. 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
  63. 63. When to Choose SQL, PL/SQL, or Perl do some formatting...
  64. 64. When to Choose SQL, PL/SQL, or Perl print formatted tag data… finish looping and end the program
  65. 65. When to Choose SQL, PL/SQL, or Perl Without the closing “ / ”, your PL/SQL code will NOT run!
  66. 66. When to Choose SQL, PL/SQL, or Perl <ul><li>Perl </li></ul>
  67. 67. When to Choose SQL, PL/SQL, or Perl <ul><li>Perl </li></ul><ul><li>invoked from the operating system </li></ul><ul><li>(can be called from within SQL(*PLUS) </li></ul>
  68. 68. When to Choose SQL, PL/SQL, or Perl <ul><li>Perl </li></ul><ul><li>invoked from the operating system </li></ul><ul><li>(can be called from within SQL(*PLUS) </li></ul><ul><li>you have control over everything, which means: </li></ul>
  69. 69. When to Choose SQL, PL/SQL, or Perl <ul><li>Perl </li></ul><ul><li>invoked from the operating system </li></ul><ul><li>(can be called from within SQL(*PLUS) </li></ul><ul><li>you have control over everything, which means: </li></ul><ul><li>relatively unlimited flexibility </li></ul><ul><li>that you have to do ALL the work </li></ul>
  70. 70. When to Choose SQL, PL/SQL, or Perl <ul><li>Perl </li></ul><ul><li>invoked from the operating system </li></ul><ul><li>(can be called from within SQL(*PLUS) </li></ul><ul><li>you have control over everything, which means: </li></ul><ul><li>relatively unlimited flexibility </li></ul><ul><li>that you have to do ALL the work </li></ul><ul><li>output to screen or file </li></ul>
  71. 71. When to Choose SQL, PL/SQL, or Perl <ul><li>Perl </li></ul><ul><li>sample of code… (Handout pages 8 -10) </li></ul><ul><li>output snippet below </li></ul>
  72. 72. When to Choose SQL, PL/SQL, or Perl start off with some comments
  73. 73. When to Choose SQL, PL/SQL, or Perl You’ll need to have DBI and DBD for Oracle set up on your Unix box.
  74. 74. When to Choose SQL, PL/SQL, or Perl set up some variables
  75. 75. When to Choose SQL, PL/SQL, or Perl need to be able to talk to the database
  76. 76. 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.
  77. 77. When to Choose SQL, PL/SQL, or Perl need to know how many columns per table to aid in output formatting
  78. 78. When to Choose SQL, PL/SQL, or Perl set up and initiate output
  79. 79. When to Choose SQL, PL/SQL, or Perl get the report’s data
  80. 80. When to Choose SQL, PL/SQL, or Perl keep track of column names ending in “_id”
  81. 81. When to Choose SQL, PL/SQL, or Perl go through array, output columns ending in “_id” first
  82. 82. When to Choose SQL, PL/SQL, or Perl go through array, output columns 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.
  83. 83. When to Choose SQL, PL/SQL, or Perl then repeat this process for columns that do not end in “_id”
  84. 84. When to Choose SQL, PL/SQL, or Perl if not enough room for smallest possible table, go to next page
  85. 85. When to Choose SQL, PL/SQL, or Perl clean up when done
  86. 86. The Batch PC
  87. 87. The Batch PC <ul><li>Should be dedicated to this task </li></ul>
  88. 88. The Batch PC <ul><li>Should be dedicated to this task </li></ul><ul><li>configuration... </li></ul>
  89. 89. The Batch PC <ul><li>Hardware </li></ul>
  90. 90. The Batch PC <ul><li>Hardware </li></ul><ul><li>older pc will be adequate </li></ul>
  91. 91. The Batch PC <ul><li>Hardware </li></ul><ul><li>older pc will be adequate </li></ul><ul><li>we’re using a 133MHz Pentium </li></ul>
  92. 92. The Batch PC <ul><li>Hardware </li></ul><ul><li>older pc will be adequate </li></ul><ul><li>we’re using a 133MHz Pentium </li></ul><ul><li>32 meg RAM </li></ul>
  93. 93. The Batch PC <ul><li>Hardware </li></ul><ul><li>older pc will be adequate </li></ul><ul><li>we’re using a 133MHz Pentium </li></ul><ul><li>32 meg RAM </li></ul><ul><li>1.5 gig hard disk, which is way more than necessary </li></ul>
  94. 94. The Batch PC <ul><li>Software </li></ul>
  95. 95. The Batch PC <ul><li>Software </li></ul><ul><li>running Windows 95 </li></ul>
  96. 96. The Batch PC <ul><li>Software </li></ul><ul><li>running Windows 95 </li></ul><ul><li>WinBatch software </li></ul><ul><li>(see www.windowware.com ) </li></ul>
  97. 97. The Batch PC <ul><li>Software </li></ul><ul><li>running Windows 95 </li></ul><ul><li>WinBatch software </li></ul><ul><li>(see www.windowware.com ) </li></ul><ul><li>the scripts that you write... </li></ul>
  98. 98. The Batch PC <ul><li>The Batch Software </li></ul>
  99. 99. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>WinBatch installation will leave it running in the background </li></ul>
  100. 100. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>WinBatch installation will leave it running in the background </li></ul><ul><li>in Windows Explorer, double click on your WinBatch script, identified as a .WBT file </li></ul>
  101. 101. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>WinBatch installation will leave it running in the background </li></ul><ul><li>in Windows Explorer, double click on your WinBatch script, identified as a .WBT file </li></ul><ul><li>it will either run right away, or appear on the task bar, awaiting its time </li></ul>
  102. 102. Quick Process Review
  103. 103. cron Cross-Platform Batch Reports Overview of Process Unix Time/date parameters in one crontab file 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 time/date parameters stored in each script copy report to destination on LAN print report to location Library Administration Library Systems Media Resources Mono Acquisitions Serials
  104. 104. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>FINALLY, a script! (Handout pages 11 & 12) </li></ul>
  105. 105. The Batch PC start off with comments, including instructions on when the script can be started safely to avoid duplication of report printing
  106. 106. The Batch PC set up paths and filenames on the Unix box and the batch PC, get the database password from a file
  107. 107. The Batch PC determine if it’s time for the script to run
  108. 108. The Batch PC Encapsulating the ftp process in a WinBatch script file works well. Use the DOS ftp program supplied with Windows.
  109. 109. The Batch PC wait a minute for ftp to complete
  110. 110. The Batch PC make sure file exists, then launch Word with it
  111. 111. The Batch PC send formatting keystrokes to Word
  112. 112. The Batch PC Get the printer pull-down menu, select the desired printer, and print. Wait a minute for printing to complete before closing Word.
  113. 113. The Batch PC The rest of the code closes loops and makes the script wait until the next run time occurs.
  114. 114. Example from another script illustrating how to trigger on day of the week. This script runs early in the morning, six days a week.
  115. 115. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>Some final hints </li></ul>
  116. 116. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>Some final hints </li></ul><ul><li>WinBatch appears to get application Windows confused, despite referring to them by name in the scripts </li></ul>
  117. 117. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>Some final hints </li></ul><ul><li>WinBatch appears to get application Windows confused, despite referring to them by name in the scripts </li></ul><ul><li>set up trigger and run times so that they do not overlap </li></ul>
  118. 118. The Batch PC <ul><li>The Batch Software </li></ul><ul><li>Some final hints </li></ul><ul><li>long lines in your scripts: </li></ul><ul><li>don’t break them up! </li></ul><ul><li>WinBatch expects them to remain </li></ul><ul><li>contiguous! </li></ul>
  119. 119. Thanks for listening Questions? Email: zimmer@wmich.edu Phone: 616.387.3885
  120. 120. Better Call Number Sorting Roll your own!
  121. 121. What Voyager gives us…
  122. 122. We can achieve better results… this is now our input correctly sorted
  123. 123. Better Call Number Sorting <ul><li>originally written in SAS back in our NOTIS days </li></ul>
  124. 124. Better Call Number Sorting <ul><li>originally written in SAS back in our NOTIS days </li></ul><ul><li>ported to Perl for use with Voyager </li></ul>
  125. 125. Better Call Number Sorting <ul><li>originally written in SAS back in our NOTIS days </li></ul><ul><li>ported to Perl for use with Voyager </li></ul><ul><li>with NOTIS, could only sort on whole call number field, with expected atrocious results </li></ul>
  126. 126. Better Call Number Sorting <ul><li>originally written in SAS back in our NOTIS days </li></ul><ul><li>ported to Perl for use with Voyager </li></ul><ul><li>with NOTIS, could only sort on whole call number field, with expected atrocious results </li></ul><ul><li>Voyager provides normalized call number, which allows for better than 80% correct sorting </li></ul>
  127. 127. Better Call Number Sorting <ul><li>with intelligent parsing applied to the call number, we can achieve about 99% correct sorting </li></ul><ul><li>implemented it as a Perl module </li></ul><ul><li>put use Sort::CallNumber; at the beginning of your Perl code </li></ul>
  128. 128. Better Call Number Sorting <ul><li>one call returns the call number chunks: </li></ul><ul><li>@cnparts = cnparse($callnum); </li></ul><ul><li>then sort on the cnparts </li></ul>
  129. 129. Thanks for listening. Contact me if you want to receive the CallNumber Perl module. Questions? Email: zimmer@wmich.edu Phone: 616.387.3885

×