Hi Paul I'm not expert in koha, but as I can see, in both cases you are accessing directly the DB; therefore the result will be the same. Doing it with perl, has the advantage that it will let you extract -if needed- some extra error/debug info if something went wrong.
In any case, you I recommend you to manually re-index your database; either with zebra or with elasticsearch. Regards, Alvaro |-----------------------------------------------------------------------------------------------------------------| Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com 2018-07-09 13:09 GMT-05:00 Paul Hoffman <p...@flo.org>: > I've been asked to modify a batch of item call numbers, substituting > "PYA" for "PZ100" whenever the latter occurs at the beginning of the > call number. This doesn't seem possible using the existing Batch Item > Modification tool (batchMod.pl). > > I would love to do this using SQL only, like so: > > UPDATE items > SET itemcallnumber = concat("PYA", substr(itemcallnumber, 6)) > WHERE itemcallnumber LIKE 'PZ100%'; > > However, I suspect that this will mess up indexing or call number browse > or *something*. Reading the relevant parts of C4::Items, I believe I > can more safely accomplish this in Perl, something along these lines... > > use C4::Items; > use C4::Context; > > use strict; > use warnings; > > my $dbh = C4::Context->dbh; > $dbh->{RaiseError} = 1; > my $sql = q{ > SELECT biblionumber, itemnumber, itemcallnumber > FROM items > WHERE itemcallnumber LIKE 'PZ100%' > }; > my $sth = $dbh->prepare($sql); > $sth->execute; > while (my ($bibnum, $itemnum, $callnum) = $sth->fetchrow_array) { > $callnum =~ s/^PZ100/PYA/; > ModItem( > {'itemcallnumber' => $callnum}, > $bibnum, > $itemnum > ) or print STDERR "Could not update item $itemnum\n"; > } > > Is this pretty much the simplest way to safely make unusual batch > modifications like this? > > Thanks in advance, > > Paul. > > -- > Paul Hoffman <p...@flo.org> > Systems Librarian > Fenway Libraries Online > c/o Wentworth Institute of Technology > 550 Huntington Ave. > Boston, MA 02115 > (617) 442-2384 (FLO main number) > _______________________________________________ > Koha mailing list http://koha-community.org > Koha@lists.katipo.co.nz > https://lists.katipo.co.nz/mailman/listinfo/koha > _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha