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.

441 lines
28KB

  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>35.8. Error Handling</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="ecpg-descriptors.html" title="35.7. Using Descriptor Areas" /><link rel="next" href="ecpg-preproc.html" title="35.9. Preprocessor Directives" /></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">35.8. Error Handling</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg-descriptors.html" title="35.7. Using Descriptor Areas">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg.html" title="Chapter 35. ECPG - Embedded SQL in C">Up</a></td><th width="60%" align="center">Chapter 35. <span xmlns="http://www.w3.org/1999/xhtml" class="application">ECPG</span> - Embedded <acronym xmlns="http://www.w3.org/1999/xhtml" class="acronym">SQL</acronym> in C</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="ecpg-preproc.html" title="35.9. Preprocessor Directives">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="ECPG-ERRORS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">35.8. Error Handling</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-WHENEVER">35.8.1. Setting Callbacks</a></span></dt><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-SQLCA">35.8.2. sqlca</a></span></dt><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-SQLSTATE-SQLCODE">35.8.3. <code class="literal">SQLSTATE</code> vs. <code class="literal">SQLCODE</code></a></span></dt></dl></div><p>
  3. This section describes how you can handle exceptional conditions
  4. and warnings in an embedded SQL program. There are two
  5. nonexclusive facilities for this.
  6. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
  7. Callbacks can be configured to handle warning and error
  8. conditions using the <code class="literal">WHENEVER</code> command.
  9. </li><li class="listitem">
  10. Detailed information about the error or warning can be obtained
  11. from the <code class="varname">sqlca</code> variable.
  12. </li></ul></div><p>
  13. </p><div class="sect2" id="ECPG-WHENEVER"><div class="titlepage"><div><div><h3 class="title">35.8.1. Setting Callbacks</h3></div></div></div><p>
  14. One simple method to catch errors and warnings is to set a
  15. specific action to be executed whenever a particular condition
  16. occurs. In general:
  17. </p><pre class="programlisting">
  18. EXEC SQL WHENEVER <em class="replaceable"><code>condition</code></em> <em class="replaceable"><code>action</code></em>;
  19. </pre><p>
  20. </p><p>
  21. <em class="replaceable"><code>condition</code></em> can be one of the following:
  22. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">SQLERROR</code></span></dt><dd><p>
  23. The specified action is called whenever an error occurs during
  24. the execution of an SQL statement.
  25. </p></dd><dt><span class="term"><code class="literal">SQLWARNING</code></span></dt><dd><p>
  26. The specified action is called whenever a warning occurs
  27. during the execution of an SQL statement.
  28. </p></dd><dt><span class="term"><code class="literal">NOT FOUND</code></span></dt><dd><p>
  29. The specified action is called whenever an SQL statement
  30. retrieves or affects zero rows. (This condition is not an
  31. error, but you might be interested in handling it specially.)
  32. </p></dd></dl></div><p>
  33. </p><p>
  34. <em class="replaceable"><code>action</code></em> can be one of the following:
  35. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">CONTINUE</code></span></dt><dd><p>
  36. This effectively means that the condition is ignored. This is
  37. the default.
  38. </p></dd><dt><span class="term"><code class="literal">GOTO <em class="replaceable"><code>label</code></em></code><br /></span><span class="term"><code class="literal">GO TO <em class="replaceable"><code>label</code></em></code></span></dt><dd><p>
  39. Jump to the specified label (using a C <code class="literal">goto</code>
  40. statement).
  41. </p></dd><dt><span class="term"><code class="literal">SQLPRINT</code></span></dt><dd><p>
  42. Print a message to standard error. This is useful for simple
  43. programs or during prototyping. The details of the message
  44. cannot be configured.
  45. </p></dd><dt><span class="term"><code class="literal">STOP</code></span></dt><dd><p>
  46. Call <code class="literal">exit(1)</code>, which will terminate the
  47. program.
  48. </p></dd><dt><span class="term"><code class="literal">DO BREAK</code></span></dt><dd><p>
  49. Execute the C statement <code class="literal">break</code>. This should
  50. only be used in loops or <code class="literal">switch</code> statements.
  51. </p></dd><dt><span class="term"><code class="literal">DO CONTINUE</code></span></dt><dd><p>
  52. Execute the C statement <code class="literal">continue</code>. This should
  53. only be used in loops statements. if executed, will cause the flow
  54. of control to return to the top of the loop.
  55. </p></dd><dt><span class="term"><code class="literal">CALL <em class="replaceable"><code>name</code></em> (<em class="replaceable"><code>args</code></em>)</code><br /></span><span class="term"><code class="literal">DO <em class="replaceable"><code>name</code></em> (<em class="replaceable"><code>args</code></em>)</code></span></dt><dd><p>
  56. Call the specified C functions with the specified arguments. (This
  57. use is different from the meaning of <code class="literal">CALL</code>
  58. and <code class="literal">DO</code> in the normal PostgreSQL grammar.)
  59. </p></dd></dl></div><p>
  60. The SQL standard only provides for the actions
  61. <code class="literal">CONTINUE</code> and <code class="literal">GOTO</code> (and
  62. <code class="literal">GO TO</code>).
  63. </p><p>
  64. Here is an example that you might want to use in a simple program.
  65. It prints a simple message when a warning occurs and aborts the
  66. program when an error happens:
  67. </p><pre class="programlisting">
  68. EXEC SQL WHENEVER SQLWARNING SQLPRINT;
  69. EXEC SQL WHENEVER SQLERROR STOP;
  70. </pre><p>
  71. </p><p>
  72. The statement <code class="literal">EXEC SQL WHENEVER</code> is a directive
  73. of the SQL preprocessor, not a C statement. The error or warning
  74. actions that it sets apply to all embedded SQL statements that
  75. appear below the point where the handler is set, unless a
  76. different action was set for the same condition between the first
  77. <code class="literal">EXEC SQL WHENEVER</code> and the SQL statement causing
  78. the condition, regardless of the flow of control in the C program.
  79. So neither of the two following C program excerpts will have the
  80. desired effect:
  81. </p><pre class="programlisting">
  82. /*
  83. * WRONG
  84. */
  85. int main(int argc, char *argv[])
  86. {
  87. ...
  88. if (verbose) {
  89. EXEC SQL WHENEVER SQLWARNING SQLPRINT;
  90. }
  91. ...
  92. EXEC SQL SELECT ...;
  93. ...
  94. }
  95. </pre><p>
  96. </p><pre class="programlisting">
  97. /*
  98. * WRONG
  99. */
  100. int main(int argc, char *argv[])
  101. {
  102. ...
  103. set_error_handler();
  104. ...
  105. EXEC SQL SELECT ...;
  106. ...
  107. }
  108. static void set_error_handler(void)
  109. {
  110. EXEC SQL WHENEVER SQLERROR STOP;
  111. }
  112. </pre><p>
  113. </p></div><div class="sect2" id="ECPG-SQLCA"><div class="titlepage"><div><div><h3 class="title">35.8.2. sqlca</h3></div></div></div><p>
  114. For more powerful error handling, the embedded SQL interface
  115. provides a global variable with the name <code class="varname">sqlca</code>
  116. (SQL communication area)
  117. that has the following structure:
  118. </p><pre class="programlisting">
  119. struct
  120. {
  121. char sqlcaid[8];
  122. long sqlabc;
  123. long sqlcode;
  124. struct
  125. {
  126. int sqlerrml;
  127. char sqlerrmc[SQLERRMC_LEN];
  128. } sqlerrm;
  129. char sqlerrp[8];
  130. long sqlerrd[6];
  131. char sqlwarn[8];
  132. char sqlstate[5];
  133. } sqlca;
  134. </pre><p>
  135. (In a multithreaded program, every thread automatically gets its
  136. own copy of <code class="varname">sqlca</code>. This works similarly to the
  137. handling of the standard C global variable
  138. <code class="varname">errno</code>.)
  139. </p><p>
  140. <code class="varname">sqlca</code> covers both warnings and errors. If
  141. multiple warnings or errors occur during the execution of a
  142. statement, then <code class="varname">sqlca</code> will only contain
  143. information about the last one.
  144. </p><p>
  145. If no error occurred in the last <acronym class="acronym">SQL</acronym> statement,
  146. <code class="literal">sqlca.sqlcode</code> will be 0 and
  147. <code class="literal">sqlca.sqlstate</code> will be
  148. <code class="literal">"00000"</code>. If a warning or error occurred, then
  149. <code class="literal">sqlca.sqlcode</code> will be negative and
  150. <code class="literal">sqlca.sqlstate</code> will be different from
  151. <code class="literal">"00000"</code>. A positive
  152. <code class="literal">sqlca.sqlcode</code> indicates a harmless condition,
  153. such as that the last query returned zero rows.
  154. <code class="literal">sqlcode</code> and <code class="literal">sqlstate</code> are two
  155. different error code schemes; details appear below.
  156. </p><p>
  157. If the last SQL statement was successful, then
  158. <code class="literal">sqlca.sqlerrd[1]</code> contains the OID of the
  159. processed row, if applicable, and
  160. <code class="literal">sqlca.sqlerrd[2]</code> contains the number of
  161. processed or returned rows, if applicable to the command.
  162. </p><p>
  163. In case of an error or warning,
  164. <code class="literal">sqlca.sqlerrm.sqlerrmc</code> will contain a string
  165. that describes the error. The field
  166. <code class="literal">sqlca.sqlerrm.sqlerrml</code> contains the length of
  167. the error message that is stored in
  168. <code class="literal">sqlca.sqlerrm.sqlerrmc</code> (the result of
  169. <code class="function">strlen()</code>, not really interesting for a C
  170. programmer). Note that some messages are too long to fit in the
  171. fixed-size <code class="literal">sqlerrmc</code> array; they will be truncated.
  172. </p><p>
  173. In case of a warning, <code class="literal">sqlca.sqlwarn[2]</code> is set
  174. to <code class="literal">W</code>. (In all other cases, it is set to
  175. something different from <code class="literal">W</code>.) If
  176. <code class="literal">sqlca.sqlwarn[1]</code> is set to
  177. <code class="literal">W</code>, then a value was truncated when it was
  178. stored in a host variable. <code class="literal">sqlca.sqlwarn[0]</code> is
  179. set to <code class="literal">W</code> if any of the other elements are set
  180. to indicate a warning.
  181. </p><p>
  182. The fields <code class="structfield">sqlcaid</code>,
  183. <code class="structfield">sqlabc</code>,
  184. <code class="structfield">sqlerrp</code>, and the remaining elements of
  185. <code class="structfield">sqlerrd</code> and
  186. <code class="structfield">sqlwarn</code> currently contain no useful
  187. information.
  188. </p><p>
  189. The structure <code class="varname">sqlca</code> is not defined in the SQL
  190. standard, but is implemented in several other SQL database
  191. systems. The definitions are similar at the core, but if you want
  192. to write portable applications, then you should investigate the
  193. different implementations carefully.
  194. </p><p>
  195. Here is one example that combines the use of <code class="literal">WHENEVER</code>
  196. and <code class="varname">sqlca</code>, printing out the contents
  197. of <code class="varname">sqlca</code> when an error occurs. This is perhaps
  198. useful for debugging or prototyping applications, before
  199. installing a more <span class="quote">“<span class="quote">user-friendly</span>”</span> error handler.
  200. </p><pre class="programlisting">
  201. EXEC SQL WHENEVER SQLERROR CALL print_sqlca();
  202. void
  203. print_sqlca()
  204. {
  205. fprintf(stderr, "==== sqlca ====\n");
  206. fprintf(stderr, "sqlcode: %ld\n", sqlca.sqlcode);
  207. fprintf(stderr, "sqlerrm.sqlerrml: %d\n", sqlca.sqlerrm.sqlerrml);
  208. fprintf(stderr, "sqlerrm.sqlerrmc: %s\n", sqlca.sqlerrm.sqlerrmc);
  209. fprintf(stderr, "sqlerrd: %ld %ld %ld %ld %ld %ld\n", sqlca.sqlerrd[0],sqlca.sqlerrd[1],sqlca.sqlerrd[2],
  210. sqlca.sqlerrd[3],sqlca.sqlerrd[4],sqlca.sqlerrd[5]);
  211. fprintf(stderr, "sqlwarn: %d %d %d %d %d %d %d %d\n", sqlca.sqlwarn[0], sqlca.sqlwarn[1], sqlca.sqlwarn[2],
  212. sqlca.sqlwarn[3], sqlca.sqlwarn[4], sqlca.sqlwarn[5],
  213. sqlca.sqlwarn[6], sqlca.sqlwarn[7]);
  214. fprintf(stderr, "sqlstate: %5s\n", sqlca.sqlstate);
  215. fprintf(stderr, "===============\n");
  216. }
  217. </pre><p>
  218. The result could look as follows (here an error due to a
  219. misspelled table name):
  220. </p><pre class="screen">
  221. ==== sqlca ====
  222. sqlcode: -400
  223. sqlerrm.sqlerrml: 49
  224. sqlerrm.sqlerrmc: relation "pg_databasep" does not exist on line 38
  225. sqlerrd: 0 0 0 0 0 0
  226. sqlwarn: 0 0 0 0 0 0 0 0
  227. sqlstate: 42P01
  228. ===============
  229. </pre><p>
  230. </p></div><div class="sect2" id="ECPG-SQLSTATE-SQLCODE"><div class="titlepage"><div><div><h3 class="title">35.8.3. <code class="literal">SQLSTATE</code> vs. <code class="literal">SQLCODE</code></h3></div></div></div><p>
  231. The fields <code class="literal">sqlca.sqlstate</code> and
  232. <code class="literal">sqlca.sqlcode</code> are two different schemes that
  233. provide error codes. Both are derived from the SQL standard, but
  234. <code class="literal">SQLCODE</code> has been marked deprecated in the SQL-92
  235. edition of the standard and has been dropped in later editions.
  236. Therefore, new applications are strongly encouraged to use
  237. <code class="literal">SQLSTATE</code>.
  238. </p><p>
  239. <code class="literal">SQLSTATE</code> is a five-character array. The five
  240. characters contain digits or upper-case letters that represent
  241. codes of various error and warning conditions.
  242. <code class="literal">SQLSTATE</code> has a hierarchical scheme: the first
  243. two characters indicate the general class of the condition, the
  244. last three characters indicate a subclass of the general
  245. condition. A successful state is indicated by the code
  246. <code class="literal">00000</code>. The <code class="literal">SQLSTATE</code> codes are for
  247. the most part defined in the SQL standard. The
  248. <span class="productname">PostgreSQL</span> server natively supports
  249. <code class="literal">SQLSTATE</code> error codes; therefore a high degree
  250. of consistency can be achieved by using this error code scheme
  251. throughout all applications. For further information see
  252. <a class="xref" href="errcodes-appendix.html" title="Appendix A. PostgreSQL Error Codes">Appendix A</a>.
  253. </p><p>
  254. <code class="literal">SQLCODE</code>, the deprecated error code scheme, is a
  255. simple integer. A value of 0 indicates success, a positive value
  256. indicates success with additional information, a negative value
  257. indicates an error. The SQL standard only defines the positive
  258. value +100, which indicates that the last command returned or
  259. affected zero rows, and no specific negative values. Therefore,
  260. this scheme can only achieve poor portability and does not have a
  261. hierarchical code assignment. Historically, the embedded SQL
  262. processor for <span class="productname">PostgreSQL</span> has assigned
  263. some specific <code class="literal">SQLCODE</code> values for its use, which
  264. are listed below with their numeric value and their symbolic name.
  265. Remember that these are not portable to other SQL implementations.
  266. To simplify the porting of applications to the
  267. <code class="literal">SQLSTATE</code> scheme, the corresponding
  268. <code class="literal">SQLSTATE</code> is also listed. There is, however, no
  269. one-to-one or one-to-many mapping between the two schemes (indeed
  270. it is many-to-many), so you should consult the global
  271. <code class="literal">SQLSTATE</code> listing in <a class="xref" href="errcodes-appendix.html" title="Appendix A. PostgreSQL Error Codes">Appendix A</a>
  272. in each case.
  273. </p><p>
  274. These are the assigned <code class="literal">SQLCODE</code> values:
  275. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">0 (<code class="symbol">ECPG_NO_ERROR</code>)</span></dt><dd><p>
  276. Indicates no error. (SQLSTATE 00000)
  277. </p></dd><dt><span class="term">100 (<code class="symbol">ECPG_NOT_FOUND</code>)</span></dt><dd><p>
  278. This is a harmless condition indicating that the last command
  279. retrieved or processed zero rows, or that you are at the end of
  280. the cursor. (SQLSTATE 02000)
  281. </p><p>
  282. When processing a cursor in a loop, you could use this code as
  283. a way to detect when to abort the loop, like this:
  284. </p><pre class="programlisting">
  285. while (1)
  286. {
  287. EXEC SQL FETCH ... ;
  288. if (sqlca.sqlcode == ECPG_NOT_FOUND)
  289. break;
  290. }
  291. </pre><p>
  292. But <code class="literal">WHENEVER NOT FOUND DO BREAK</code> effectively
  293. does this internally, so there is usually no advantage in
  294. writing this out explicitly.
  295. </p></dd><dt><span class="term">-12 (<code class="symbol">ECPG_OUT_OF_MEMORY</code>)</span></dt><dd><p>
  296. Indicates that your virtual memory is exhausted. The numeric
  297. value is defined as <code class="literal">-ENOMEM</code>. (SQLSTATE
  298. YE001)
  299. </p></dd><dt><span class="term">-200 (<code class="symbol">ECPG_UNSUPPORTED</code>)</span></dt><dd><p>
  300. Indicates the preprocessor has generated something that the
  301. library does not know about. Perhaps you are running
  302. incompatible versions of the preprocessor and the
  303. library. (SQLSTATE YE002)
  304. </p></dd><dt><span class="term">-201 (<code class="symbol">ECPG_TOO_MANY_ARGUMENTS</code>)</span></dt><dd><p>
  305. This means that the command specified more host variables than
  306. the command expected. (SQLSTATE 07001 or 07002)
  307. </p></dd><dt><span class="term">-202 (<code class="symbol">ECPG_TOO_FEW_ARGUMENTS</code>)</span></dt><dd><p>
  308. This means that the command specified fewer host variables than
  309. the command expected. (SQLSTATE 07001 or 07002)
  310. </p></dd><dt><span class="term">-203 (<code class="symbol">ECPG_TOO_MANY_MATCHES</code>)</span></dt><dd><p>
  311. This means a query has returned multiple rows but the statement
  312. was only prepared to store one result row (for example, because
  313. the specified variables are not arrays). (SQLSTATE 21000)
  314. </p></dd><dt><span class="term">-204 (<code class="symbol">ECPG_INT_FORMAT</code>)</span></dt><dd><p>
  315. The host variable is of type <code class="type">int</code> and the datum in
  316. the database is of a different type and contains a value that
  317. cannot be interpreted as an <code class="type">int</code>. The library uses
  318. <code class="function">strtol()</code> for this conversion. (SQLSTATE
  319. 42804)
  320. </p></dd><dt><span class="term">-205 (<code class="symbol">ECPG_UINT_FORMAT</code>)</span></dt><dd><p>
  321. The host variable is of type <code class="type">unsigned int</code> and the
  322. datum in the database is of a different type and contains a
  323. value that cannot be interpreted as an <code class="type">unsigned
  324. int</code>. The library uses <code class="function">strtoul()</code>
  325. for this conversion. (SQLSTATE 42804)
  326. </p></dd><dt><span class="term">-206 (<code class="symbol">ECPG_FLOAT_FORMAT</code>)</span></dt><dd><p>
  327. The host variable is of type <code class="type">float</code> and the datum
  328. in the database is of another type and contains a value that
  329. cannot be interpreted as a <code class="type">float</code>. The library
  330. uses <code class="function">strtod()</code> for this conversion.
  331. (SQLSTATE 42804)
  332. </p></dd><dt><span class="term">-207 (<code class="symbol">ECPG_NUMERIC_FORMAT</code>)</span></dt><dd><p>
  333. The host variable is of type <code class="type">numeric</code> and the datum
  334. in the database is of another type and contains a value that
  335. cannot be interpreted as a <code class="type">numeric</code> value.
  336. (SQLSTATE 42804)
  337. </p></dd><dt><span class="term">-208 (<code class="symbol">ECPG_INTERVAL_FORMAT</code>)</span></dt><dd><p>
  338. The host variable is of type <code class="type">interval</code> and the datum
  339. in the database is of another type and contains a value that
  340. cannot be interpreted as an <code class="type">interval</code> value.
  341. (SQLSTATE 42804)
  342. </p></dd><dt><span class="term">-209 (<code class="symbol">ECPG_DATE_FORMAT</code>)</span></dt><dd><p>
  343. The host variable is of type <code class="type">date</code> and the datum in
  344. the database is of another type and contains a value that
  345. cannot be interpreted as a <code class="type">date</code> value.
  346. (SQLSTATE 42804)
  347. </p></dd><dt><span class="term">-210 (<code class="symbol">ECPG_TIMESTAMP_FORMAT</code>)</span></dt><dd><p>
  348. The host variable is of type <code class="type">timestamp</code> and the
  349. datum in the database is of another type and contains a value
  350. that cannot be interpreted as a <code class="type">timestamp</code> value.
  351. (SQLSTATE 42804)
  352. </p></dd><dt><span class="term">-211 (<code class="symbol">ECPG_CONVERT_BOOL</code>)</span></dt><dd><p>
  353. This means the host variable is of type <code class="type">bool</code> and
  354. the datum in the database is neither <code class="literal">'t'</code> nor
  355. <code class="literal">'f'</code>. (SQLSTATE 42804)
  356. </p></dd><dt><span class="term">-212 (<code class="symbol">ECPG_EMPTY</code>)</span></dt><dd><p>
  357. The statement sent to the <span class="productname">PostgreSQL</span>
  358. server was empty. (This cannot normally happen in an embedded
  359. SQL program, so it might point to an internal error.) (SQLSTATE
  360. YE002)
  361. </p></dd><dt><span class="term">-213 (<code class="symbol">ECPG_MISSING_INDICATOR</code>)</span></dt><dd><p>
  362. A null value was returned and no null indicator variable was
  363. supplied. (SQLSTATE 22002)
  364. </p></dd><dt><span class="term">-214 (<code class="symbol">ECPG_NO_ARRAY</code>)</span></dt><dd><p>
  365. An ordinary variable was used in a place that requires an
  366. array. (SQLSTATE 42804)
  367. </p></dd><dt><span class="term">-215 (<code class="symbol">ECPG_DATA_NOT_ARRAY</code>)</span></dt><dd><p>
  368. The database returned an ordinary variable in a place that
  369. requires array value. (SQLSTATE 42804)
  370. </p></dd><dt><span class="term">-216 (<code class="symbol">ECPG_ARRAY_INSERT</code>)</span></dt><dd><p>
  371. The value could not be inserted into the array. (SQLSTATE
  372. 42804)
  373. </p></dd><dt><span class="term">-220 (<code class="symbol">ECPG_NO_CONN</code>)</span></dt><dd><p>
  374. The program tried to access a connection that does not exist.
  375. (SQLSTATE 08003)
  376. </p></dd><dt><span class="term">-221 (<code class="symbol">ECPG_NOT_CONN</code>)</span></dt><dd><p>
  377. The program tried to access a connection that does exist but is
  378. not open. (This is an internal error.) (SQLSTATE YE002)
  379. </p></dd><dt><span class="term">-230 (<code class="symbol">ECPG_INVALID_STMT</code>)</span></dt><dd><p>
  380. The statement you are trying to use has not been prepared.
  381. (SQLSTATE 26000)
  382. </p></dd><dt><span class="term">-239 (<code class="symbol">ECPG_INFORMIX_DUPLICATE_KEY</code>)</span></dt><dd><p>
  383. Duplicate key error, violation of unique constraint (Informix
  384. compatibility mode). (SQLSTATE 23505)
  385. </p></dd><dt><span class="term">-240 (<code class="symbol">ECPG_UNKNOWN_DESCRIPTOR</code>)</span></dt><dd><p>
  386. The descriptor specified was not found. The statement you are
  387. trying to use has not been prepared. (SQLSTATE 33000)
  388. </p></dd><dt><span class="term">-241 (<code class="symbol">ECPG_INVALID_DESCRIPTOR_INDEX</code>)</span></dt><dd><p>
  389. The descriptor index specified was out of range. (SQLSTATE
  390. 07009)
  391. </p></dd><dt><span class="term">-242 (<code class="symbol">ECPG_UNKNOWN_DESCRIPTOR_ITEM</code>)</span></dt><dd><p>
  392. An invalid descriptor item was requested. (This is an internal
  393. error.) (SQLSTATE YE002)
  394. </p></dd><dt><span class="term">-243 (<code class="symbol">ECPG_VAR_NOT_NUMERIC</code>)</span></dt><dd><p>
  395. During the execution of a dynamic statement, the database
  396. returned a numeric value and the host variable was not numeric.
  397. (SQLSTATE 07006)
  398. </p></dd><dt><span class="term">-244 (<code class="symbol">ECPG_VAR_NOT_CHAR</code>)</span></dt><dd><p>
  399. During the execution of a dynamic statement, the database
  400. returned a non-numeric value and the host variable was numeric.
  401. (SQLSTATE 07006)
  402. </p></dd><dt><span class="term">-284 (<code class="symbol">ECPG_INFORMIX_SUBSELECT_NOT_ONE</code>)</span></dt><dd><p>
  403. A result of the subquery is not single row (Informix
  404. compatibility mode). (SQLSTATE 21000)
  405. </p></dd><dt><span class="term">-400 (<code class="symbol">ECPG_PGSQL</code>)</span></dt><dd><p>
  406. Some error caused by the <span class="productname">PostgreSQL</span>
  407. server. The message contains the error message from the
  408. <span class="productname">PostgreSQL</span> server.
  409. </p></dd><dt><span class="term">-401 (<code class="symbol">ECPG_TRANS</code>)</span></dt><dd><p>
  410. The <span class="productname">PostgreSQL</span> server signaled that
  411. we cannot start, commit, or rollback the transaction.
  412. (SQLSTATE 08007)
  413. </p></dd><dt><span class="term">-402 (<code class="symbol">ECPG_CONNECT</code>)</span></dt><dd><p>
  414. The connection attempt to the database did not succeed.
  415. (SQLSTATE 08001)
  416. </p></dd><dt><span class="term">-403 (<code class="symbol">ECPG_DUPLICATE_KEY</code>)</span></dt><dd><p>
  417. Duplicate key error, violation of unique constraint. (SQLSTATE
  418. 23505)
  419. </p></dd><dt><span class="term">-404 (<code class="symbol">ECPG_SUBSELECT_NOT_ONE</code>)</span></dt><dd><p>
  420. A result for the subquery is not single row. (SQLSTATE 21000)
  421. </p></dd><dt><span class="term">-602 (<code class="symbol">ECPG_WARNING_UNKNOWN_PORTAL</code>)</span></dt><dd><p>
  422. An invalid cursor name was specified. (SQLSTATE 34000)
  423. </p></dd><dt><span class="term">-603 (<code class="symbol">ECPG_WARNING_IN_TRANSACTION</code>)</span></dt><dd><p>
  424. Transaction is in progress. (SQLSTATE 25001)
  425. </p></dd><dt><span class="term">-604 (<code class="symbol">ECPG_WARNING_NO_TRANSACTION</code>)</span></dt><dd><p>
  426. There is no active (in-progress) transaction. (SQLSTATE 25P01)
  427. </p></dd><dt><span class="term">-605 (<code class="symbol">ECPG_WARNING_PORTAL_EXISTS</code>)</span></dt><dd><p>
  428. An existing cursor name was specified. (SQLSTATE 42P03)
  429. </p></dd></dl></div><p>
  430. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg-descriptors.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-preproc.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">35.7. Using Descriptor Areas </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 35.9. Preprocessor Directives</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1