Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/isn.sgml`
bee2a4121224d680c98cdb24aa080194406020a2a96148480000000100000d6f
 <function>is_valid</function> function and cleared with the
   <function>make_valid</function> function.
  </para>

  <para>
   You can also force the insertion of marked-as-invalid numbers even when not
   in the weak mode, by appending the <literal>!</literal> character at the
   end of the number.
  </para>

  <para>
   Another special feature is that during input, you can write
   <literal>?</literal> in place of the check digit, and the correct check digit
   will be inserted automatically.
  </para>
 </sect2>

 <sect2 id="isn-examples">
  <title>Examples</title>

<programlisting>
--Using the types directly:
SELECT isbn('978-0-393-04002-9');
SELECT isbn13('0901690546');
SELECT issn('1436-4522');

--Casting types:
-- note that you can only cast from ean13 to another type when the
-- number would be valid in the realm of the target type;
-- thus, the following will NOT work: select isbn(ean13('0220356483481'));
-- but these will:
SELECT upc(ean13('0220356483481'));
SELECT ean13(upc('220356483481'));

--Create a table with a single column to hold ISBN numbers:
CREATE TABLE test (id isbn);
INSERT INTO test VALUES('9780393040029');

--Automatically calculate check digits (observe the '?'):
INSERT INTO test VALUES('220500896?');
INSERT INTO test VALUES('978055215372?');

SELECT issn('3251231?');
SELECT ismn('979047213542?');

--Using the weak mode:
SET isn.weak TO true;
INSERT INTO test VALUES('978-0-11-000533-4');
INSERT INTO test VALUES('9780141219307');
INSERT INTO test VALUES('2-205-00876-X');
SET isn.weak TO false;

SELECT id FROM test WHERE NOT is_valid(id);
UPDATE test SET id = make_valid(id) WHERE id = '2-205-00876-X!';

SELECT * FROM test;

SELECT isbn13(id) FROM test;
</programlisting>
 </sect2>

 <sect2 id="isn-bibliography">
  <title>Bibliography</title>

  <para>
   The information to implement this module was collected from
   several sites, including:
   <itemizedlist>
    <listitem><para><ulink url="https://www.isbn-international.org/"></ulink></para></listitem>
    <listitem><para><ulink url="https://www.issn.org/"></ulink></para></listitem>
    <listitem><para><ulink url="https://www.ismn-international.org/"></ulink></para></listitem>
    <listitem><para><ulink url="https://www.wikipedia.org/"></ulink></para></listitem>
   </itemizedlist>

   The prefixes used for hyphenation were also compiled from:
   <itemizedlist>
    <listitem><para><ulink url="https://www.gs1.org/standards/id-keys"></ulink></para></listitem>
    <listitem><para><ulink url="https://en.wikipedia.org/wiki/List_of_ISBN_registration_groups"></ulink></para></listitem>
    <listitem><para><ulink url="https://www.isbn-international.org/content/isbn-users-manual/29"></ulink></para></listitem>
    <listitem><para><ulink url="https://en.wikipedia.org/wiki/International_Standard_Music_Number"></ulink></para></listitem>
    <listitem><para><ulink url="https://www.ismn-international.org/ranges/tools"></ulink></para></listitem>
   </itemizedlist>

   Care was taken during the creation of the algorithms and they
   were meticulously verified against the suggested algorithms
   in the official ISBN, ISMN, ISSN User Manuals.
  </para>
 </sect2>

 <sect2 id="isn-author">
  <title>Author</title>
  <para>
   Germ&aacute;n M&eacute;ndez Bravo (Kronuz), 2004&ndash;2006
  </para>

  <para>
   This module was inspired by Garrett A. Wollman's
   <filename>isbn_issn</filename> code.
  </para>
 </sect2>

</sect1>

Title: ISN Module: Examples, Bibliography, and Author
Summary
The section provides examples of using the ISN module, including creating tables, inserting values, and using the weak mode, as well as a bibliography of sources used to implement the module, and information about the module's author and inspiration.