Presentation is loading. Please wait.

Presentation is loading. Please wait.

using non-Cobol programs

Similar presentations


Presentation on theme: "using non-Cobol programs"— Presentation transcript:

1 using non-Cobol programs
Expand routines using non-Cobol programs Version 21 rep_ver # IGeLU A Ori Miller, Aleph Support Manager

2 Agenda Introduction Example Example with SQL
Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

3 Introduction Purpose of Enhancement
In tab_expand and tab_fix we have a variety of programs to modify our records. fix_doc_do_file_08 is very flexible, but not everything can be done with it. Into tab_fix we can define a program that the library programers can write, in any language. Now it is also possible to do it in tab_expand Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

4 Introduction Here is the formal description of the development:
Expand mechanism allows adding bibliographic information to a record in certain places in the system. This development enhance expand mechanism to allow using external program not supplied by ALEPH (as exists in fix_doc mechanism). Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

5 Agenda Introduction Example Example with SQL
Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

6 Configuration Add a line such as the following to tab_expand : !
! COL ; ALPHA_NUM, UPPER; -; ! Expand Menu; ! COL ; ALPHA_NUM, LOWER; _; ! Expand procedure; ! COL ; ALPHA_NUM; ; ! Program arguments; ! !!!!!!!!!!-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!> TEST external_prog.pl Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

7 The program Create the file $aleph_exe/external_prog.pl (this example is in the perl programming language) Pay attention to the path to perl and run: chmod a+x $aleph_exe/external_prog.pl #!/exlibris/aleph/a21_1/product/bin/perl use strict; use warnings; while (<>) { # read lines from BIB record, one by one my $in = $_ ; if ($in =~ /^245/) { # for field 245 $in =~ s/\$\$a/\$\$p/; # change $$a to $$p } print "$in"; # the output of the program is the modified record Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

8 Example If the program is not in $aleph_exe, or if we forgot to “chmod” it, we will get the following error: Error: function TEST missing program <external_prog.pl > It is always a good idea to test it with util-f-4/doc_expand The $$a in 245 is now displayed as $$p enter file name (or q to exit) doc_expand Enter expand_menu [No Expand]: TEST ENTER DOC NUMBER : 1234 Reading doc : Load: /tmp/utf_files/exlibris/aleph/a21_1/usm01/tab/tab_expand FMT L SE ... 24500 L $$pHistory and theory. Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

9 UNIX script Similar example, this time with a UNIX script:
tab_expand: TEST external_prog.csh Create: $aleph_exe/external_prog.csh Run: chmod a+x $aleph_exe/external_prog.csh #!/bin/csh set skip_first_line = "$<" while (1) set in = "$<" if ("$in" == "") exit set field = `echo "$in" | cut -c1-3` if ($field == "245") then echo "$in" | sed 's/a/p/' > /tmp/field.$$ set in = "`cat /tmp/field.$$`" endif echo "$in" end Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

10 Agenda Introduction Example Example with SQL
Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

11 SQL from within the expand program
#!/exlibris/aleph/a21_1/product/bin/perl use strict; use warnings; use DBI; # Change according to: echo $ORACLE_HOME $ENV{'ORACLE_HOME'} = '/exlibris/app/oracle/product/11r2'; # Change according to: echo $aleph_db my $Database = 'il-aleph20.aleph21'; # Change to Oracle user needed: my $orauser = 'usm01'; my $orapass = 'usm01'; my $dsn = "DBI:Oracle:$Database"; my $dbh = DBI->connect($dsn, $orauser, $orapass); my $doc_num = " "; while (<>) { # read lines from BIB record, one by one my $in = $_ ; if ($in =~/^USM01(.*)/) { $doc_num = $1; } else { } #print "DEBUG: THE DOC NUMBER: $doc_num\n"; my $sql = "select count(*) COUNT from z13 where Z13_AUTHOR=" . "(select Z13_AUTHOR from z13 where Z13_REC_KEY=$doc_num)"; #print "DEBUG: THE SQL: $sql\n"; my $sth = $dbh->prepare($sql); $sth->execute; my $sql_output = 'NA'; while( my $ref = $sth->fetchrow_hashref() ) { $sql_output = $ref->{'COUNT'}; #print "DEBUG: THE sql_output:$sql_output\n"; $dbh->disconnect; foreach my $in { if ($in =~ /^100/) { # add a sub-field $$0 for field 100 $in =~s/$/\$\$0number of other records with this author:$sql_output/; print "$in"; # the output of the program is the modified record Perl program which includes an SQL. It finds other books (in Z13) which have the same author as the book we are viewing. Unlike our competitors, we did not release a new revolutionized system every few years but rather took the evolutionary approach

12


Download ppt "using non-Cobol programs"

Similar presentations


Ads by Google