[OPEN-ILS-GENERAL] Error creating MARC record

Dan Scott denials at gmail.com
Thu Mar 12 15:24:10 EDT 2009


2009/3/12 Levani EL <levaniele at gmail.com>:
> hello
> i have problem record marc and import record via z3950.from staff
> client 1.4.2.2  i install sample 500 documents is is work good. when i
> create marc record i see Error creating marc record
> "ilsevent" : 2002  "textcode"_database Query_Failed" ....
> when i run settings-tester.pl i see like that:

My guess is that, now that you have imported 500 records, you need to
update the bib record sequences. Here's what's probably happening:

1. There is a bib record sequence for bib ID and for TCN. These start
generating the next value of 1, in a freshly created database.

2. You import 500 records through a batch import. If I recall
correctly, these are assigned the bib ID numbers 1 through 500. (A
"SELECT id FROM biblio.record_entry" in psql would quickly confirm
that for you).

3. You attempt to import a record via Z39.50. The bib ID sequence
happily hands off what it thinks is the first ID to be used in the
database, 1, to be used for identifying this row.

4. Upon attempting to insert this row, the database freaks out because
having two rows with the same ID (1) violates its uniqueness
constraint on the ID column (as a consequence of being the primary
key). The Z39.50 record, being the second of the rows identified as 1
to try to get into the database, gets rolled back, and the "query
failed" error bubbles up to the surface. The next value of the bib ID
sequence is now 2.

5. Ergo, you would have to try 499 more failed imports to advance the
next value of the bib ID sequence to 501 before you would have success
by avoiding trying to insert a duplicate ID value.

To avoid this problem after a bulk import, you need to invoke the
SETVAL function to update the next value of the bib ID sequence.
Issuing the following:

SELECT SETVAL('biblio.record_entry_id_seq', 501);

would set the next value of the sequence to 501, but that's brittle
because someone else may have imported some records in bulk
subsequently. A much more convenient method is:


SELECT SETVAL('biblio.record_entry_id_seq', (
    SELECT MAX(id) + 1 FROM biblio.record_entry)
);

... which sets the next value of the sequence the maximum value of the
ID column in the biblio.record_entry database, plus 1 to avoid a
conflict.

You can face the same situation for biblio.autogen_tcn_value_seq.

-- 
Dan Scott
Laurentian University


More information about the Open-ils-general mailing list