[Koha-patches] [PATCH] Update MARC to add 099$c and 099$d fields, with :

Galen Charlton galen.charlton at liblime.com
Wed Nov 19 20:11:45 CET 2008


Hi,

Since this is UNIMARC only, please add a check to prevent it from
running if the marcflavour is wrong.  I also suggest renaming it to
sync_unimarc_bib_with_marc_biblio.pl.

Regards,

Galen

On Wed, Nov 19, 2008 at 9:49 AM, Henri-Damien LAURENT
<henridamien.laurent at biblibre.com> wrote:
> This allow the acquisition date sorting in UNIMARC.
> ---
>  misc/maintenance/sync_bib_with_marc_biblio.pl |   69 +++++++++++++++++++++++++
>  1 files changed, 69 insertions(+), 0 deletions(-)
>  create mode 100644 misc/maintenance/sync_bib_with_marc_biblio.pl
>
> diff --git a/misc/maintenance/sync_bib_with_marc_biblio.pl b/misc/maintenance/sync_bib_with_marc_biblio.pl
> new file mode 100644
> index 0000000..e966348
> --- /dev/null
> +++ b/misc/maintenance/sync_bib_with_marc_biblio.pl
> @@ -0,0 +1,69 @@
> +#!/usr/bin/perl
> +#
> +# This script should be used only with UNIMARC flavour
> +# It is designed to report some missing information from biblio
> +# table into  marc data
> +#
> +use strict;
> +use warnings;
> +
> +BEGIN {
> +    use FindBin;
> +    eval { require "$FindBin::Bin/../kohalib.pl" };
> +}
> +
> +use C4::Biblio;
> +
> +sub updateMarc {
> +    my $id = shift;
> +    my $dbh = C4::Context->dbh;
> +    my $field;
> +    my $biblio = GetMarcBiblio($id);
> +
> +    if(!$biblio->field('099'))
> +    {
> +        $field = new MARC::Field('099','','',
> +                    'c' => '',
> +                    'd'=>'');
> +        $biblio->add_fields($field);
> +    }
> +
> +    $field = $biblio->field('099');
> +
> +    my $sth = $dbh->prepare("SELECT DATE_FORMAT(datecreated,'%Y-%m-%d') as datecreated,
> +                                    DATE_FORMAT(timestamp,'%Y-%m-%d') as timestamp,
> +                                    frameworkcode
> +                                    FROM biblio
> +                                    WHERE biblionumber = ?");
> +    $sth->execute($id);
> +    (my $bibliorow = $sth->fetchrow_hashref);
> +    my $frameworkcode = $bibliorow->{'frameworkcode'};
> +
> +    $field->update( 'c' => $bibliorow->{'datecreated'},
> +                    'd' => $bibliorow->{'timestamp'}
> +                    );
> +
> +     if(&ModBiblio($biblio, $id, $frameworkcode))
> +     {
> +        print "\r$id";
> +     }
> +
> +}
> +
> +sub process {
> +
> +    my $dbh = C4::Context->dbh;
> +
> +    my $sth = $dbh->prepare("SELECT biblionumber FROM biblio");
> +    $sth->execute();
> +
> +    while(my $biblios = $sth->fetchrow_hashref)
> +    {
> +        updateMarc($biblios->{'biblionumber'});
> +        print ".";
> +    }
> +
> +}
> +
> +
> +process();
> --
> 1.6.0.2
>
> _______________________________________________
> Koha-patches mailing list
> Koha-patches at lists.koha.org
> http://lists.koha.org/mailman/listinfo/koha-patches
>



-- 
Galen Charlton
VP, Research & Development, LibLime
galen.charlton at liblime.com
p: 1-888-564-2457 x709
skype: gmcharlt



More information about the Koha-patches mailing list