gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 satır
15KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.19. isn</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="intarray.html" title="F.18. intarray" /><link rel="next" href="lo.html" title="F.20. lo" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.19. isn</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="intarray.html" title="F.18. intarray">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="lo.html" title="F.20. lo">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="ISN"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.19. isn</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="isn.html#id-1.11.7.28.4">F.19.1. Data Types</a></span></dt><dt><span class="sect2"><a href="isn.html#id-1.11.7.28.5">F.19.2. Casts</a></span></dt><dt><span class="sect2"><a href="isn.html#id-1.11.7.28.6">F.19.3. Functions and Operators</a></span></dt><dt><span class="sect2"><a href="isn.html#id-1.11.7.28.7">F.19.4. Examples</a></span></dt><dt><span class="sect2"><a href="isn.html#id-1.11.7.28.8">F.19.5. Bibliography</a></span></dt><dt><span class="sect2"><a href="isn.html#id-1.11.7.28.9">F.19.6. Author</a></span></dt></dl></div><a id="id-1.11.7.28.2" class="indexterm"></a><p>
  3. The <code class="filename">isn</code> module provides data types for the following
  4. international product numbering standards: EAN13, UPC, ISBN (books), ISMN
  5. (music), and ISSN (serials). Numbers are validated on input according to a
  6. hard-coded list of prefixes; this list of prefixes is also used to hyphenate
  7. numbers on output. Since new prefixes are assigned from time to time, the
  8. list of prefixes may be out of date. It is hoped that a future version of
  9. this module will obtained the prefix list from one or more tables that
  10. can be easily updated by users as needed; however, at present, the
  11. list can only be updated by modifying the source code and recompiling.
  12. Alternatively, prefix validation and hyphenation support may be
  13. dropped from a future version of this module.
  14. </p><div class="sect2" id="id-1.11.7.28.4"><div class="titlepage"><div><div><h3 class="title">F.19.1. Data Types</h3></div></div></div><p>
  15. <a class="xref" href="isn.html#ISN-DATATYPES" title="Table F.11. isn Data Types">Table F.11</a> shows the data types provided by
  16. the <code class="filename">isn</code> module.
  17. </p><div class="table" id="ISN-DATATYPES"><p class="title"><strong>Table F.11. <code class="filename">isn</code> Data Types</strong></p><div class="table-contents"><table class="table" summary="isn Data Types" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Data Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="type">EAN13</code></td><td>
  18. European Article Numbers, always displayed in the EAN13 display format
  19. </td></tr><tr><td><code class="type">ISBN13</code></td><td>
  20. International Standard Book Numbers to be displayed in
  21. the new EAN13 display format
  22. </td></tr><tr><td><code class="type">ISMN13</code></td><td>
  23. International Standard Music Numbers to be displayed in
  24. the new EAN13 display format
  25. </td></tr><tr><td><code class="type">ISSN13</code></td><td>
  26. International Standard Serial Numbers to be displayed in the new
  27. EAN13 display format
  28. </td></tr><tr><td><code class="type">ISBN</code></td><td>
  29. International Standard Book Numbers to be displayed in the old
  30. short display format
  31. </td></tr><tr><td><code class="type">ISMN</code></td><td>
  32. International Standard Music Numbers to be displayed in the
  33. old short display format
  34. </td></tr><tr><td><code class="type">ISSN</code></td><td>
  35. International Standard Serial Numbers to be displayed in the
  36. old short display format
  37. </td></tr><tr><td><code class="type">UPC</code></td><td>
  38. Universal Product Codes
  39. </td></tr></tbody></table></div></div><br class="table-break" /><p>
  40. Some notes:
  41. </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>ISBN13, ISMN13, ISSN13 numbers are all EAN13 numbers.</p></li><li class="listitem"><p>EAN13 numbers aren't always ISBN13, ISMN13 or ISSN13 (some
  42. are).</p></li><li class="listitem"><p>Some ISBN13 numbers can be displayed as ISBN.</p></li><li class="listitem"><p>Some ISMN13 numbers can be displayed as ISMN.</p></li><li class="listitem"><p>Some ISSN13 numbers can be displayed as ISSN.</p></li><li class="listitem"><p>UPC numbers are a subset of the EAN13 numbers (they are basically
  43. EAN13 without the first <code class="literal">0</code> digit).</p></li><li class="listitem"><p>All UPC, ISBN, ISMN and ISSN numbers can be represented as EAN13
  44. numbers.</p></li></ol></div><p>
  45. Internally, all these types use the same representation (a 64-bit
  46. integer), and all are interchangeable. Multiple types are provided
  47. to control display formatting and to permit tighter validity checking
  48. of input that is supposed to denote one particular type of number.
  49. </p><p>
  50. The <code class="type">ISBN</code>, <code class="type">ISMN</code>, and <code class="type">ISSN</code> types will display the
  51. short version of the number (ISxN 10) whenever it's possible, and will show
  52. ISxN 13 format for numbers that do not fit in the short version.
  53. The <code class="type">EAN13</code>, <code class="type">ISBN13</code>, <code class="type">ISMN13</code> and
  54. <code class="type">ISSN13</code> types will always display the long version of the ISxN
  55. (EAN13).
  56. </p></div><div class="sect2" id="id-1.11.7.28.5"><div class="titlepage"><div><div><h3 class="title">F.19.2. Casts</h3></div></div></div><p>
  57. The <code class="filename">isn</code> module provides the following pairs of type casts:
  58. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  59. ISBN13 &lt;=&gt; EAN13
  60. </p></li><li class="listitem"><p>
  61. ISMN13 &lt;=&gt; EAN13
  62. </p></li><li class="listitem"><p>
  63. ISSN13 &lt;=&gt; EAN13
  64. </p></li><li class="listitem"><p>
  65. ISBN &lt;=&gt; EAN13
  66. </p></li><li class="listitem"><p>
  67. ISMN &lt;=&gt; EAN13
  68. </p></li><li class="listitem"><p>
  69. ISSN &lt;=&gt; EAN13
  70. </p></li><li class="listitem"><p>
  71. UPC &lt;=&gt; EAN13
  72. </p></li><li class="listitem"><p>
  73. ISBN &lt;=&gt; ISBN13
  74. </p></li><li class="listitem"><p>
  75. ISMN &lt;=&gt; ISMN13
  76. </p></li><li class="listitem"><p>
  77. ISSN &lt;=&gt; ISSN13
  78. </p></li></ul></div><p>
  79. When casting from <code class="type">EAN13</code> to another type, there is a run-time
  80. check that the value is within the domain of the other type, and an error
  81. is thrown if not. The other casts are simply relabelings that will
  82. always succeed.
  83. </p></div><div class="sect2" id="id-1.11.7.28.6"><div class="titlepage"><div><div><h3 class="title">F.19.3. Functions and Operators</h3></div></div></div><p>
  84. The <code class="filename">isn</code> module provides the standard comparison operators,
  85. plus B-tree and hash indexing support for all these data types. In
  86. addition there are several specialized functions; shown in <a class="xref" href="isn.html#ISN-FUNCTIONS" title="Table F.12. isn Functions">Table F.12</a>.
  87. In this table,
  88. <code class="type">isn</code> means any one of the module's data types.
  89. </p><div class="table" id="ISN-FUNCTIONS"><p class="title"><strong>Table F.12. <code class="filename">isn</code> Functions</strong></p><div class="table-contents"><table class="table" summary="isn Functions" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Function</th><th>Returns</th><th>Description</th></tr></thead><tbody><tr><td><code class="function">isn_weak(boolean)</code><a id="id-1.11.7.28.6.3.2.2.1.1.2" class="indexterm"></a></td><td><code class="type">boolean</code></td><td>Sets the weak input mode (returns new setting)</td></tr><tr><td><code class="function">isn_weak()</code></td><td><code class="type">boolean</code></td><td>Gets the current status of the weak mode</td></tr><tr><td><code class="function">make_valid(isn)</code><a id="id-1.11.7.28.6.3.2.2.3.1.2" class="indexterm"></a></td><td><code class="type">isn</code></td><td>Validates an invalid number (clears the invalid flag)</td></tr><tr><td><code class="function">is_valid(isn)</code><a id="id-1.11.7.28.6.3.2.2.4.1.2" class="indexterm"></a></td><td><code class="type">boolean</code></td><td>Checks for the presence of the invalid flag</td></tr></tbody></table></div></div><br class="table-break" /><p>
  90. <em class="firstterm">Weak</em> mode is used to be able to insert invalid data
  91. into a table. Invalid means the check digit is wrong, not that there are
  92. missing numbers.
  93. </p><p>
  94. Why would you want to use the weak mode? Well, it could be that
  95. you have a huge collection of ISBN numbers, and that there are so many of
  96. them that for weird reasons some have the wrong check digit (perhaps the
  97. numbers were scanned from a printed list and the OCR got the numbers wrong,
  98. perhaps the numbers were manually captured... who knows). Anyway, the point
  99. is you might want to clean the mess up, but you still want to be able to
  100. have all the numbers in your database and maybe use an external tool to
  101. locate the invalid numbers in the database so you can verify the
  102. information and validate it more easily; so for example you'd want to
  103. select all the invalid numbers in the table.
  104. </p><p>
  105. When you insert invalid numbers in a table using the weak mode, the number
  106. will be inserted with the corrected check digit, but it will be displayed
  107. with an exclamation mark (<code class="literal">!</code>) at the end, for example
  108. <code class="literal">0-11-000322-5!</code>. This invalid marker can be checked with
  109. the <code class="function">is_valid</code> function and cleared with the
  110. <code class="function">make_valid</code> function.
  111. </p><p>
  112. You can also force the insertion of invalid numbers even when not in the
  113. weak mode, by appending the <code class="literal">!</code> character at the end of the
  114. number.
  115. </p><p>
  116. Another special feature is that during input, you can write
  117. <code class="literal">?</code> in place of the check digit, and the correct check digit
  118. will be inserted automatically.
  119. </p></div><div class="sect2" id="id-1.11.7.28.7"><div class="titlepage"><div><div><h3 class="title">F.19.4. Examples</h3></div></div></div><pre class="programlisting">
  120. --Using the types directly:
  121. SELECT isbn('978-0-393-04002-9');
  122. SELECT isbn13('0901690546');
  123. SELECT issn('1436-4522');
  124. --Casting types:
  125. -- note that you can only cast from ean13 to another type when the
  126. -- number would be valid in the realm of the target type;
  127. -- thus, the following will NOT work: select isbn(ean13('0220356483481'));
  128. -- but these will:
  129. SELECT upc(ean13('0220356483481'));
  130. SELECT ean13(upc('220356483481'));
  131. --Create a table with a single column to hold ISBN numbers:
  132. CREATE TABLE test (id isbn);
  133. INSERT INTO test VALUES('9780393040029');
  134. --Automatically calculate check digits (observe the '?'):
  135. INSERT INTO test VALUES('220500896?');
  136. INSERT INTO test VALUES('978055215372?');
  137. SELECT issn('3251231?');
  138. SELECT ismn('979047213542?');
  139. --Using the weak mode:
  140. SELECT isn_weak(true);
  141. INSERT INTO test VALUES('978-0-11-000533-4');
  142. INSERT INTO test VALUES('9780141219307');
  143. INSERT INTO test VALUES('2-205-00876-X');
  144. SELECT isn_weak(false);
  145. SELECT id FROM test WHERE NOT is_valid(id);
  146. UPDATE test SET id = make_valid(id) WHERE id = '2-205-00876-X!';
  147. SELECT * FROM test;
  148. SELECT isbn13(id) FROM test;
  149. </pre></div><div class="sect2" id="id-1.11.7.28.8"><div class="titlepage"><div><div><h3 class="title">F.19.5. Bibliography</h3></div></div></div><p>
  150. The information to implement this module was collected from
  151. several sites, including:
  152. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="ulink" href="https://www.isbn-international.org/" target="_top">https://www.isbn-international.org/</a></p></li><li class="listitem"><p><a class="ulink" href="https://www.issn.org/" target="_top">https://www.issn.org/</a></p></li><li class="listitem"><p><a class="ulink" href="https://www.ismn-international.org/" target="_top">https://www.ismn-international.org/</a></p></li><li class="listitem"><p><a class="ulink" href="https://www.wikipedia.org/" target="_top">https://www.wikipedia.org/</a></p></li></ul></div><p>
  153. The prefixes used for hyphenation were also compiled from:
  154. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="ulink" href="https://www.gs1.org/standards/id-keys" target="_top">https://www.gs1.org/standards/id-keys</a></p></li><li class="listitem"><p><a class="ulink" href="https://en.wikipedia.org/wiki/List_of_ISBN_identifier_groups" target="_top">https://en.wikipedia.org/wiki/List_of_ISBN_identifier_groups</a></p></li><li class="listitem"><p><a class="ulink" href="https://www.isbn-international.org/content/isbn-users-manual" target="_top">https://www.isbn-international.org/content/isbn-users-manual</a></p></li><li class="listitem"><p><a class="ulink" href="https://en.wikipedia.org/wiki/International_Standard_Music_Number" target="_top">https://en.wikipedia.org/wiki/International_Standard_Music_Number</a></p></li><li class="listitem"><p><a class="ulink" href="https://www.ismn-international.org/ranges.html" target="_top">https://www.ismn-international.org/ranges.html</a></p></li></ul></div><p>
  155. Care was taken during the creation of the algorithms and they
  156. were meticulously verified against the suggested algorithms
  157. in the official ISBN, ISMN, ISSN User Manuals.
  158. </p></div><div class="sect2" id="id-1.11.7.28.9"><div class="titlepage"><div><div><h3 class="title">F.19.6. Author</h3></div></div></div><p>
  159. Germán Méndez Bravo (Kronuz), 2004 - 2006
  160. </p><p>
  161. This module was inspired by Garrett A. Wollman's
  162. <code class="filename">isbn_issn</code> code.
  163. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="intarray.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="lo.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.18. intarray </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> F.20. lo</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1