????
Current Path : C:/opt/pgsql/doc/postgresql/html/ |
Current File : C:/opt/pgsql/doc/postgresql/html/ecpg-errors.html |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!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>36.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 Vsnapshot" /><link rel="prev" href="ecpg-descriptors.html" title="36.7. Using Descriptor Areas" /><link rel="next" href="ecpg-preproc.html" title="36.9. Preprocessor Directives" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">36.8. Error Handling</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg-descriptors.html" title="36.7. Using Descriptor Areas">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Up</a></td><th width="60%" align="center">Chapter 36. <span class="application">ECPG</span> — Embedded <acronym class="acronym">SQL</acronym> in C</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-preproc.html" title="36.9. Preprocessor Directives">Next</a></td></tr></table><hr /></div><div class="sect1" id="ECPG-ERRORS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">36.8. Error Handling <a href="#ECPG-ERRORS" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-WHENEVER">36.8.1. Setting Callbacks</a></span></dt><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-SQLCA">36.8.2. sqlca</a></span></dt><dt><span class="sect2"><a href="ecpg-errors.html#ECPG-SQLSTATE-SQLCODE">36.8.3. <code class="literal">SQLSTATE</code> vs. <code class="literal">SQLCODE</code></a></span></dt></dl></div><p> This section describes how you can handle exceptional conditions and warnings in an embedded SQL program. There are two nonexclusive facilities for this. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> Callbacks can be configured to handle warning and error conditions using the <code class="literal">WHENEVER</code> command. </li><li class="listitem"> Detailed information about the error or warning can be obtained from the <code class="varname">sqlca</code> variable. </li></ul></div><p> </p><div class="sect2" id="ECPG-WHENEVER"><div class="titlepage"><div><div><h3 class="title">36.8.1. Setting Callbacks <a href="#ECPG-WHENEVER" class="id_link">#</a></h3></div></div></div><p> One simple method to catch errors and warnings is to set a specific action to be executed whenever a particular condition occurs. In general: </p><pre class="programlisting"> EXEC SQL WHENEVER <em class="replaceable"><code>condition</code></em> <em class="replaceable"><code>action</code></em>; </pre><p> </p><p> <em class="replaceable"><code>condition</code></em> can be one of the following: </p><div class="variablelist"><dl class="variablelist"><dt id="ECPG-WHENEVER-SQLERROR"><span class="term"><code class="literal">SQLERROR</code></span> <a href="#ECPG-WHENEVER-SQLERROR" class="id_link">#</a></dt><dd><p> The specified action is called whenever an error occurs during the execution of an SQL statement. </p></dd><dt id="ECPG-WHENEVER-SQLWARNING"><span class="term"><code class="literal">SQLWARNING</code></span> <a href="#ECPG-WHENEVER-SQLWARNING" class="id_link">#</a></dt><dd><p> The specified action is called whenever a warning occurs during the execution of an SQL statement. </p></dd><dt id="ECPG-WHENEVER-NOT-FOUND"><span class="term"><code class="literal">NOT FOUND</code></span> <a href="#ECPG-WHENEVER-NOT-FOUND" class="id_link">#</a></dt><dd><p> The specified action is called whenever an SQL statement retrieves or affects zero rows. (This condition is not an error, but you might be interested in handling it specially.) </p></dd></dl></div><p> </p><p> <em class="replaceable"><code>action</code></em> can be one of the following: </p><div class="variablelist"><dl class="variablelist"><dt id="ECPG-WHENEVER-CONTINUE"><span class="term"><code class="literal">CONTINUE</code></span> <a href="#ECPG-WHENEVER-CONTINUE" class="id_link">#</a></dt><dd><p> This effectively means that the condition is ignored. This is the default. </p></dd><dt id="ECPG-WHENEVER-GOTO"><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> <a href="#ECPG-WHENEVER-GOTO" class="id_link">#</a></dt><dd><p> Jump to the specified label (using a C <code class="literal">goto</code> statement). </p></dd><dt id="ECPG-WHENEVER-SQLPRINT"><span class="term"><code class="literal">SQLPRINT</code></span> <a href="#ECPG-WHENEVER-SQLPRINT" class="id_link">#</a></dt><dd><p> Print a message to standard error. This is useful for simple programs or during prototyping. The details of the message cannot be configured. </p></dd><dt id="ECPG-WHENEVER-STOP"><span class="term"><code class="literal">STOP</code></span> <a href="#ECPG-WHENEVER-STOP" class="id_link">#</a></dt><dd><p> Call <code class="literal">exit(1)</code>, which will terminate the program. </p></dd><dt id="ECPG-WHENEVER-DO-BREAK"><span class="term"><code class="literal">DO BREAK</code></span> <a href="#ECPG-WHENEVER-DO-BREAK" class="id_link">#</a></dt><dd><p> Execute the C statement <code class="literal">break</code>. This should only be used in loops or <code class="literal">switch</code> statements. </p></dd><dt id="ECPG-WHENEVER-DO-CONTINUE"><span class="term"><code class="literal">DO CONTINUE</code></span> <a href="#ECPG-WHENEVER-DO-CONTINUE" class="id_link">#</a></dt><dd><p> Execute the C statement <code class="literal">continue</code>. This should only be used in loops statements. if executed, will cause the flow of control to return to the top of the loop. </p></dd><dt id="ECPG-WHENEVER-CALL"><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> <a href="#ECPG-WHENEVER-CALL" class="id_link">#</a></dt><dd><p> Call the specified C functions with the specified arguments. (This use is different from the meaning of <code class="literal">CALL</code> and <code class="literal">DO</code> in the normal PostgreSQL grammar.) </p></dd></dl></div><p> The SQL standard only provides for the actions <code class="literal">CONTINUE</code> and <code class="literal">GOTO</code> (and <code class="literal">GO TO</code>). </p><p> Here is an example that you might want to use in a simple program. It prints a simple message when a warning occurs and aborts the program when an error happens: </p><pre class="programlisting"> EXEC SQL WHENEVER SQLWARNING SQLPRINT; EXEC SQL WHENEVER SQLERROR STOP; </pre><p> </p><p> The statement <code class="literal">EXEC SQL WHENEVER</code> is a directive of the SQL preprocessor, not a C statement. The error or warning actions that it sets apply to all embedded SQL statements that appear below the point where the handler is set, unless a different action was set for the same condition between the first <code class="literal">EXEC SQL WHENEVER</code> and the SQL statement causing the condition, regardless of the flow of control in the C program. So neither of the two following C program excerpts will have the desired effect: </p><pre class="programlisting"> /* * WRONG */ int main(int argc, char *argv[]) { ... if (verbose) { EXEC SQL WHENEVER SQLWARNING SQLPRINT; } ... EXEC SQL SELECT ...; ... } </pre><p> </p><pre class="programlisting"> /* * WRONG */ int main(int argc, char *argv[]) { ... set_error_handler(); ... EXEC SQL SELECT ...; ... } static void set_error_handler(void) { EXEC SQL WHENEVER SQLERROR STOP; } </pre><p> </p></div><div class="sect2" id="ECPG-SQLCA"><div class="titlepage"><div><div><h3 class="title">36.8.2. sqlca <a href="#ECPG-SQLCA" class="id_link">#</a></h3></div></div></div><p> For more powerful error handling, the embedded SQL interface provides a global variable with the name <code class="varname">sqlca</code> (SQL communication area) that has the following structure: </p><pre class="programlisting"> struct { char sqlcaid[8]; long sqlabc; long sqlcode; struct { int sqlerrml; char sqlerrmc[SQLERRMC_LEN]; } sqlerrm; char sqlerrp[8]; long sqlerrd[6]; char sqlwarn[8]; char sqlstate[5]; } sqlca; </pre><p> (In a multithreaded program, every thread automatically gets its own copy of <code class="varname">sqlca</code>. This works similarly to the handling of the standard C global variable <code class="varname">errno</code>.) </p><p> <code class="varname">sqlca</code> covers both warnings and errors. If multiple warnings or errors occur during the execution of a statement, then <code class="varname">sqlca</code> will only contain information about the last one. </p><p> If no error occurred in the last <acronym class="acronym">SQL</acronym> statement, <code class="literal">sqlca.sqlcode</code> will be 0 and <code class="literal">sqlca.sqlstate</code> will be <code class="literal">"00000"</code>. If a warning or error occurred, then <code class="literal">sqlca.sqlcode</code> will be negative and <code class="literal">sqlca.sqlstate</code> will be different from <code class="literal">"00000"</code>. A positive <code class="literal">sqlca.sqlcode</code> indicates a harmless condition, such as that the last query returned zero rows. <code class="literal">sqlcode</code> and <code class="literal">sqlstate</code> are two different error code schemes; details appear below. </p><p> If the last SQL statement was successful, then <code class="literal">sqlca.sqlerrd[1]</code> contains the OID of the processed row, if applicable, and <code class="literal">sqlca.sqlerrd[2]</code> contains the number of processed or returned rows, if applicable to the command. </p><p> In case of an error or warning, <code class="literal">sqlca.sqlerrm.sqlerrmc</code> will contain a string that describes the error. The field <code class="literal">sqlca.sqlerrm.sqlerrml</code> contains the length of the error message that is stored in <code class="literal">sqlca.sqlerrm.sqlerrmc</code> (the result of <code class="function">strlen()</code>, not really interesting for a C programmer). Note that some messages are too long to fit in the fixed-size <code class="literal">sqlerrmc</code> array; they will be truncated. </p><p> In case of a warning, <code class="literal">sqlca.sqlwarn[2]</code> is set to <code class="literal">W</code>. (In all other cases, it is set to something different from <code class="literal">W</code>.) If <code class="literal">sqlca.sqlwarn[1]</code> is set to <code class="literal">W</code>, then a value was truncated when it was stored in a host variable. <code class="literal">sqlca.sqlwarn[0]</code> is set to <code class="literal">W</code> if any of the other elements are set to indicate a warning. </p><p> The fields <code class="structfield">sqlcaid</code>, <code class="structfield">sqlabc</code>, <code class="structfield">sqlerrp</code>, and the remaining elements of <code class="structfield">sqlerrd</code> and <code class="structfield">sqlwarn</code> currently contain no useful information. </p><p> The structure <code class="varname">sqlca</code> is not defined in the SQL standard, but is implemented in several other SQL database systems. The definitions are similar at the core, but if you want to write portable applications, then you should investigate the different implementations carefully. </p><p> Here is one example that combines the use of <code class="literal">WHENEVER</code> and <code class="varname">sqlca</code>, printing out the contents of <code class="varname">sqlca</code> when an error occurs. This is perhaps useful for debugging or prototyping applications, before installing a more <span class="quote">“<span class="quote">user-friendly</span>”</span> error handler. </p><pre class="programlisting"> EXEC SQL WHENEVER SQLERROR CALL print_sqlca(); void print_sqlca() { fprintf(stderr, "==== sqlca ====\n"); fprintf(stderr, "sqlcode: %ld\n", sqlca.sqlcode); fprintf(stderr, "sqlerrm.sqlerrml: %d\n", sqlca.sqlerrm.sqlerrml); fprintf(stderr, "sqlerrm.sqlerrmc: %s\n", sqlca.sqlerrm.sqlerrmc); fprintf(stderr, "sqlerrd: %ld %ld %ld %ld %ld %ld\n", sqlca.sqlerrd[0],sqlca.sqlerrd[1],sqlca.sqlerrd[2], sqlca.sqlerrd[3],sqlca.sqlerrd[4],sqlca.sqlerrd[5]); fprintf(stderr, "sqlwarn: %d %d %d %d %d %d %d %d\n", sqlca.sqlwarn[0], sqlca.sqlwarn[1], sqlca.sqlwarn[2], sqlca.sqlwarn[3], sqlca.sqlwarn[4], sqlca.sqlwarn[5], sqlca.sqlwarn[6], sqlca.sqlwarn[7]); fprintf(stderr, "sqlstate: %5s\n", sqlca.sqlstate); fprintf(stderr, "===============\n"); } </pre><p> The result could look as follows (here an error due to a misspelled table name): </p><pre class="screen"> ==== sqlca ==== sqlcode: -400 sqlerrm.sqlerrml: 49 sqlerrm.sqlerrmc: relation "pg_databasep" does not exist on line 38 sqlerrd: 0 0 0 0 0 0 sqlwarn: 0 0 0 0 0 0 0 0 sqlstate: 42P01 =============== </pre><p> </p></div><div class="sect2" id="ECPG-SQLSTATE-SQLCODE"><div class="titlepage"><div><div><h3 class="title">36.8.3. <code class="literal">SQLSTATE</code> vs. <code class="literal">SQLCODE</code> <a href="#ECPG-SQLSTATE-SQLCODE" class="id_link">#</a></h3></div></div></div><p> The fields <code class="literal">sqlca.sqlstate</code> and <code class="literal">sqlca.sqlcode</code> are two different schemes that provide error codes. Both are derived from the SQL standard, but <code class="literal">SQLCODE</code> has been marked deprecated in the SQL-92 edition of the standard and has been dropped in later editions. Therefore, new applications are strongly encouraged to use <code class="literal">SQLSTATE</code>. </p><p> <code class="literal">SQLSTATE</code> is a five-character array. The five characters contain digits or upper-case letters that represent codes of various error and warning conditions. <code class="literal">SQLSTATE</code> has a hierarchical scheme: the first two characters indicate the general class of the condition, the last three characters indicate a subclass of the general condition. A successful state is indicated by the code <code class="literal">00000</code>. The <code class="literal">SQLSTATE</code> codes are for the most part defined in the SQL standard. The <span class="productname">PostgreSQL</span> server natively supports <code class="literal">SQLSTATE</code> error codes; therefore a high degree of consistency can be achieved by using this error code scheme throughout all applications. For further information see <a class="xref" href="errcodes-appendix.html" title="Appendix A. PostgreSQL Error Codes">Appendix A</a>. </p><p> <code class="literal">SQLCODE</code>, the deprecated error code scheme, is a simple integer. A value of 0 indicates success, a positive value indicates success with additional information, a negative value indicates an error. The SQL standard only defines the positive value +100, which indicates that the last command returned or affected zero rows, and no specific negative values. Therefore, this scheme can only achieve poor portability and does not have a hierarchical code assignment. Historically, the embedded SQL processor for <span class="productname">PostgreSQL</span> has assigned some specific <code class="literal">SQLCODE</code> values for its use, which are listed below with their numeric value and their symbolic name. Remember that these are not portable to other SQL implementations. To simplify the porting of applications to the <code class="literal">SQLSTATE</code> scheme, the corresponding <code class="literal">SQLSTATE</code> is also listed. There is, however, no one-to-one or one-to-many mapping between the two schemes (indeed it is many-to-many), so you should consult the global <code class="literal">SQLSTATE</code> listing in <a class="xref" href="errcodes-appendix.html" title="Appendix A. PostgreSQL Error Codes">Appendix A</a> in each case. </p><p> These are the assigned <code class="literal">SQLCODE</code> values: </p><div class="variablelist"><dl class="variablelist"><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-NO-ERROR"><span class="term">0 (<code class="symbol">ECPG_NO_ERROR</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-NO-ERROR" class="id_link">#</a></dt><dd><p> Indicates no error. (SQLSTATE 00000) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-NOT-FOUND"><span class="term">100 (<code class="symbol">ECPG_NOT_FOUND</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-NOT-FOUND" class="id_link">#</a></dt><dd><p> This is a harmless condition indicating that the last command retrieved or processed zero rows, or that you are at the end of the cursor. (SQLSTATE 02000) </p><p> When processing a cursor in a loop, you could use this code as a way to detect when to abort the loop, like this: </p><pre class="programlisting"> while (1) { EXEC SQL FETCH ... ; if (sqlca.sqlcode == ECPG_NOT_FOUND) break; } </pre><p> But <code class="literal">WHENEVER NOT FOUND DO BREAK</code> effectively does this internally, so there is usually no advantage in writing this out explicitly. </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-OUT-OF-MEMORY"><span class="term">-12 (<code class="symbol">ECPG_OUT_OF_MEMORY</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-OUT-OF-MEMORY" class="id_link">#</a></dt><dd><p> Indicates that your virtual memory is exhausted. The numeric value is defined as <code class="literal">-ENOMEM</code>. (SQLSTATE YE001) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-UNSUPPORTED"><span class="term">-200 (<code class="symbol">ECPG_UNSUPPORTED</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-UNSUPPORTED" class="id_link">#</a></dt><dd><p> Indicates the preprocessor has generated something that the library does not know about. Perhaps you are running incompatible versions of the preprocessor and the library. (SQLSTATE YE002) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-TOO-MANY-ARGUMENTS"><span class="term">-201 (<code class="symbol">ECPG_TOO_MANY_ARGUMENTS</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-TOO-MANY-ARGUMENTS" class="id_link">#</a></dt><dd><p> This means that the command specified more host variables than the command expected. (SQLSTATE 07001 or 07002) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-TOO-FEW-ARGUMENTS"><span class="term">-202 (<code class="symbol">ECPG_TOO_FEW_ARGUMENTS</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-TOO-FEW-ARGUMENTS" class="id_link">#</a></dt><dd><p> This means that the command specified fewer host variables than the command expected. (SQLSTATE 07001 or 07002) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-TOO-MANY-MATCHES"><span class="term">-203 (<code class="symbol">ECPG_TOO_MANY_MATCHES</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-TOO-MANY-MATCHES" class="id_link">#</a></dt><dd><p> This means a query has returned multiple rows but the statement was only prepared to store one result row (for example, because the specified variables are not arrays). (SQLSTATE 21000) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-INT-FORMAT"><span class="term">-204 (<code class="symbol">ECPG_INT_FORMAT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-INT-FORMAT" class="id_link">#</a></dt><dd><p> The host variable is of type <code class="type">int</code> and the datum in the database is of a different type and contains a value that cannot be interpreted as an <code class="type">int</code>. The library uses <code class="function">strtol()</code> for this conversion. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-UINT-FORMAT"><span class="term">-205 (<code class="symbol">ECPG_UINT_FORMAT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-UINT-FORMAT" class="id_link">#</a></dt><dd><p> The host variable is of type <code class="type">unsigned int</code> and the datum in the database is of a different type and contains a value that cannot be interpreted as an <code class="type">unsigned int</code>. The library uses <code class="function">strtoul()</code> for this conversion. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-FLOAT-FORMAT"><span class="term">-206 (<code class="symbol">ECPG_FLOAT_FORMAT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-FLOAT-FORMAT" class="id_link">#</a></dt><dd><p> The host variable is of type <code class="type">float</code> and the datum in the database is of another type and contains a value that cannot be interpreted as a <code class="type">float</code>. The library uses <code class="function">strtod()</code> for this conversion. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-NUMERIC-FORMAT"><span class="term">-207 (<code class="symbol">ECPG_NUMERIC_FORMAT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-NUMERIC-FORMAT" class="id_link">#</a></dt><dd><p> The host variable is of type <code class="type">numeric</code> and the datum in the database is of another type and contains a value that cannot be interpreted as a <code class="type">numeric</code> value. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-INTERVAL-FORMAT"><span class="term">-208 (<code class="symbol">ECPG_INTERVAL_FORMAT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-INTERVAL-FORMAT" class="id_link">#</a></dt><dd><p> The host variable is of type <code class="type">interval</code> and the datum in the database is of another type and contains a value that cannot be interpreted as an <code class="type">interval</code> value. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-DATE-FORMAT"><span class="term">-209 (<code class="symbol">ECPG_DATE_FORMAT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-DATE-FORMAT" class="id_link">#</a></dt><dd><p> The host variable is of type <code class="type">date</code> and the datum in the database is of another type and contains a value that cannot be interpreted as a <code class="type">date</code> value. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-TIMESTAMP-FORMAT"><span class="term">-210 (<code class="symbol">ECPG_TIMESTAMP_FORMAT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-TIMESTAMP-FORMAT" class="id_link">#</a></dt><dd><p> The host variable is of type <code class="type">timestamp</code> and the datum in the database is of another type and contains a value that cannot be interpreted as a <code class="type">timestamp</code> value. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-CONVERT-BOOL"><span class="term">-211 (<code class="symbol">ECPG_CONVERT_BOOL</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-CONVERT-BOOL" class="id_link">#</a></dt><dd><p> This means the host variable is of type <code class="type">bool</code> and the datum in the database is neither <code class="literal">'t'</code> nor <code class="literal">'f'</code>. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-EMPTY"><span class="term">-212 (<code class="symbol">ECPG_EMPTY</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-EMPTY" class="id_link">#</a></dt><dd><p> The statement sent to the <span class="productname">PostgreSQL</span> server was empty. (This cannot normally happen in an embedded SQL program, so it might point to an internal error.) (SQLSTATE YE002) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-MISSING-INDICATOR"><span class="term">-213 (<code class="symbol">ECPG_MISSING_INDICATOR</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-MISSING-INDICATOR" class="id_link">#</a></dt><dd><p> A null value was returned and no null indicator variable was supplied. (SQLSTATE 22002) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-NO-ARRAY"><span class="term">-214 (<code class="symbol">ECPG_NO_ARRAY</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-NO-ARRAY" class="id_link">#</a></dt><dd><p> An ordinary variable was used in a place that requires an array. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-DATA-NOT-ARRAY"><span class="term">-215 (<code class="symbol">ECPG_DATA_NOT_ARRAY</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-DATA-NOT-ARRAY" class="id_link">#</a></dt><dd><p> The database returned an ordinary variable in a place that requires array value. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-ARRAY-INSERT"><span class="term">-216 (<code class="symbol">ECPG_ARRAY_INSERT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-ARRAY-INSERT" class="id_link">#</a></dt><dd><p> The value could not be inserted into the array. (SQLSTATE 42804) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-NO-CONN"><span class="term">-220 (<code class="symbol">ECPG_NO_CONN</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-NO-CONN" class="id_link">#</a></dt><dd><p> The program tried to access a connection that does not exist. (SQLSTATE 08003) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-NOT-CONN"><span class="term">-221 (<code class="symbol">ECPG_NOT_CONN</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-NOT-CONN" class="id_link">#</a></dt><dd><p> The program tried to access a connection that does exist but is not open. (This is an internal error.) (SQLSTATE YE002) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-INVALID-STMT"><span class="term">-230 (<code class="symbol">ECPG_INVALID_STMT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-INVALID-STMT" class="id_link">#</a></dt><dd><p> The statement you are trying to use has not been prepared. (SQLSTATE 26000) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-INFORMIX-DUPLICATE-KEY"><span class="term">-239 (<code class="symbol">ECPG_INFORMIX_DUPLICATE_KEY</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-INFORMIX-DUPLICATE-KEY" class="id_link">#</a></dt><dd><p> Duplicate key error, violation of unique constraint (Informix compatibility mode). (SQLSTATE 23505) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-UNKNOWN-DESCRIPTOR"><span class="term">-240 (<code class="symbol">ECPG_UNKNOWN_DESCRIPTOR</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-UNKNOWN-DESCRIPTOR" class="id_link">#</a></dt><dd><p> The descriptor specified was not found. The statement you are trying to use has not been prepared. (SQLSTATE 33000) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-INVALID-DESCRIPTOR-INDEX"><span class="term">-241 (<code class="symbol">ECPG_INVALID_DESCRIPTOR_INDEX</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-INVALID-DESCRIPTOR-INDEX" class="id_link">#</a></dt><dd><p> The descriptor index specified was out of range. (SQLSTATE 07009) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-UNKNOWN-DESCRIPTOR-ITEM"><span class="term">-242 (<code class="symbol">ECPG_UNKNOWN_DESCRIPTOR_ITEM</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-UNKNOWN-DESCRIPTOR-ITEM" class="id_link">#</a></dt><dd><p> An invalid descriptor item was requested. (This is an internal error.) (SQLSTATE YE002) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-VAR-NOT-NUMERIC"><span class="term">-243 (<code class="symbol">ECPG_VAR_NOT_NUMERIC</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-VAR-NOT-NUMERIC" class="id_link">#</a></dt><dd><p> During the execution of a dynamic statement, the database returned a numeric value and the host variable was not numeric. (SQLSTATE 07006) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-VAR-NOT-CHAR"><span class="term">-244 (<code class="symbol">ECPG_VAR_NOT_CHAR</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-VAR-NOT-CHAR" class="id_link">#</a></dt><dd><p> During the execution of a dynamic statement, the database returned a non-numeric value and the host variable was numeric. (SQLSTATE 07006) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-INFORMIX-SUBSELECT-NOT-ONE"><span class="term">-284 (<code class="symbol">ECPG_INFORMIX_SUBSELECT_NOT_ONE</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-INFORMIX-SUBSELECT-NOT-ONE" class="id_link">#</a></dt><dd><p> A result of the subquery is not single row (Informix compatibility mode). (SQLSTATE 21000) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-PGSQL"><span class="term">-400 (<code class="symbol">ECPG_PGSQL</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-PGSQL" class="id_link">#</a></dt><dd><p> Some error caused by the <span class="productname">PostgreSQL</span> server. The message contains the error message from the <span class="productname">PostgreSQL</span> server. </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-TRANS"><span class="term">-401 (<code class="symbol">ECPG_TRANS</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-TRANS" class="id_link">#</a></dt><dd><p> The <span class="productname">PostgreSQL</span> server signaled that we cannot start, commit, or rollback the transaction. (SQLSTATE 08007) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-CONNECT"><span class="term">-402 (<code class="symbol">ECPG_CONNECT</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-CONNECT" class="id_link">#</a></dt><dd><p> The connection attempt to the database did not succeed. (SQLSTATE 08001) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-DUPLICATE-KEY"><span class="term">-403 (<code class="symbol">ECPG_DUPLICATE_KEY</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-DUPLICATE-KEY" class="id_link">#</a></dt><dd><p> Duplicate key error, violation of unique constraint. (SQLSTATE 23505) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-SUBSELECT-NOT-ONE"><span class="term">-404 (<code class="symbol">ECPG_SUBSELECT_NOT_ONE</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-SUBSELECT-NOT-ONE" class="id_link">#</a></dt><dd><p> A result for the subquery is not single row. (SQLSTATE 21000) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-UNKNOWN-PORTAL"><span class="term">-602 (<code class="symbol">ECPG_WARNING_UNKNOWN_PORTAL</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-UNKNOWN-PORTAL" class="id_link">#</a></dt><dd><p> An invalid cursor name was specified. (SQLSTATE 34000) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-IN-TRANSACTION"><span class="term">-603 (<code class="symbol">ECPG_WARNING_IN_TRANSACTION</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-IN-TRANSACTION" class="id_link">#</a></dt><dd><p> Transaction is in progress. (SQLSTATE 25001) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-NO-TRANSACTION"><span class="term">-604 (<code class="symbol">ECPG_WARNING_NO_TRANSACTION</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-NO-TRANSACTION" class="id_link">#</a></dt><dd><p> There is no active (in-progress) transaction. (SQLSTATE 25P01) </p></dd><dt id="ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-PORTAL-EXISTS"><span class="term">-605 (<code class="symbol">ECPG_WARNING_PORTAL_EXISTS</code>)</span> <a href="#ECPG-SQLSTATE-SQLCODE-ECPG-WARNING-PORTAL-EXISTS" class="id_link">#</a></dt><dd><p> An existing cursor name was specified. (SQLSTATE 42P03) </p></dd></dl></div><p> </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" title="36.7. Using Descriptor Areas">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-preproc.html" title="36.9. Preprocessor Directives">Next</a></td></tr><tr><td width="40%" align="left" valign="top">36.7. Using Descriptor Areas </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 36.9. Preprocessor Directives</td></tr></table></div></body></html>