Commit 028c7252 authored by Peter Eisentraut's avatar Peter Eisentraut

Reformat some non-sensical markup.

parent d6b2d6b6
No related merge requests found
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ecpg.sgml,v 1.26 2001/10/18 20:43:05 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ecpg.sgml,v 1.27 2001/10/31 20:37:39 petere Exp $
--> -->
<chapter id="ecpg"> <chapter id="ecpg">
...@@ -120,27 +120,27 @@ $Header: /cvsroot/pgsql/doc/src/sgml/ecpg.sgml,v 1.26 2001/10/18 20:43:05 momjia ...@@ -120,27 +120,27 @@ $Header: /cvsroot/pgsql/doc/src/sgml/ecpg.sgml,v 1.26 2001/10/18 20:43:05 momjia
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
<function>ECPGdebug(int <replaceable>on</replaceable>, FILE <function>ECPGdebug(int <replaceable>on</replaceable>, FILE
*<replaceable>stream</replaceable>)</function> turns on debug *<replaceable>stream</replaceable>)</function> turns on debug
logging if called with the first argument non-zero. Debug logging if called with the first argument non-zero. Debug
logging is done on <replaceable>stream</replaceable>. Most logging is done on <replaceable>stream</replaceable>. Most
<acronym>SQL</acronym> statement log their arguments and results. <acronym>SQL</acronym> statement log their arguments and results.
</para> </para>
<para> <para>
The most important function , <function>ECPGdo</function>, logs The most important function , <function>ECPGdo</function>, logs
all <acronym>SQL</acronym> statements with both the expanded all <acronym>SQL</acronym> statements with both the expanded
string, i.e. the string with all the input variables inserted, string, i.e. the string with all the input variables inserted,
and the result from the <productname>Postgres</productname> and the result from the <productname>Postgres</productname>
server. This can be very useful when searching for errors in server. This can be very useful when searching for errors in
your <acronym>SQL</acronym> statements. your <acronym>SQL</acronym> statements.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<function>ECPGstatus()</function> <function>ECPGstatus()</function>
This method returns TRUE if we are connected to a database and FALSE if not. This method returns TRUE if we are connected to a database and FALSE if not.
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
...@@ -180,7 +180,7 @@ struct sqlca ...@@ -180,7 +180,7 @@ struct sqlca
/* 5: empty */ /* 5: empty */
char sqlwarn[8]; char sqlwarn[8];
/* 0: set to 'W' if at least one other is 'W' */ /* 0: set to 'W' if at least one other is 'W' */
/* 1: if 'W' at least one character string */ /* 1: if 'W' at least one character string */
/* value was truncated when it was */ /* value was truncated when it was */
/* stored into a host variable. */ /* stored into a host variable. */
/* 2: empty */ /* 2: empty */
...@@ -216,265 +216,265 @@ struct sqlca ...@@ -216,265 +216,265 @@ struct sqlca
<varlistentry> <varlistentry>
<term><computeroutput>-12, Out of memory in line %d.</computeroutput></term> <term><computeroutput>-12, Out of memory in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
Should not normally occur. This indicates your virtual memory is Should not normally occur. This indicates your virtual memory is
exhausted. exhausted.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-200 (ECPG_UNSUPPORTED): Unsupported type %s on line %d.</computeroutput></term> <term><computeroutput>-200 (ECPG_UNSUPPORTED): Unsupported type %s on line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
Should not normally occur. This indicates the preprocessor has Should not normally occur. This indicates the preprocessor has
generated something that the library does not know about. generated something that the library does not know about.
Perhaps you are running incompatible versions of the Perhaps you are running incompatible versions of the
preprocessor and the library. preprocessor and the library.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-201 (ECPG_TOO_MANY_ARGUMENTS): Too many arguments line %d.</computeroutput></term> <term><computeroutput>-201 (ECPG_TOO_MANY_ARGUMENTS): Too many arguments line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This means that <productname>Postgres</productname> has This means that <productname>Postgres</productname> has
returned more arguments than we have matching variables. returned more arguments than we have matching variables.
Perhaps you have forgotten a couple of the host variables in Perhaps you have forgotten a couple of the host variables in
the <command>INTO :var1,:var2</command>-list. the <command>INTO :var1,:var2</command>-list.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-202 (ECPG_TOO_FEW_ARGUMENTS): Too few arguments line %d.</computeroutput></term> <term><computeroutput>-202 (ECPG_TOO_FEW_ARGUMENTS): Too few arguments line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This means that <productname>Postgres</productname> has This means that <productname>Postgres</productname> has
returned fewer arguments than we have host variables. Perhaps returned fewer arguments than we have host variables. Perhaps
you have too many host variables in the <command>INTO you have too many host variables in the <command>INTO
:var1,:var2</command>-list. :var1,:var2</command>-list.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-203 (ECPG_TOO_MANY_MATCHES): Too many matches line %d.</computeroutput></term> <term><computeroutput>-203 (ECPG_TOO_MANY_MATCHES): Too many matches line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This means the query has returned several rows but the This means the query has returned several rows but the
variables specified are not arrays. The variables specified are not arrays. The
<command>SELECT</command> command was not unique. <command>SELECT</command> command was not unique.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-204 (ECPG_INT_FORMAT): Not correctly formatted int type: %s line %d.</computeroutput></term> <term><computeroutput>-204 (ECPG_INT_FORMAT): Not correctly formatted int type: %s line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This means the host variable is of type <type>int</type> and This means the host variable is of type <type>int</type> and
the field in the <productname>Postgres</productname> database the field in the <productname>Postgres</productname> database
is of another type and contains a value that cannot be is of another type and contains a value that cannot be
interpreted as an <type>int</type>. The library uses interpreted as an <type>int</type>. The library uses
<function>strtol()</function> for this conversion. <function>strtol()</function> for this conversion.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-205 (ECPG_UINT_FORMAT): Not correctly formatted unsigned type: %s line %d.</computeroutput></term> <term><computeroutput>-205 (ECPG_UINT_FORMAT): Not correctly formatted unsigned type: %s line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This means the host variable is of type <type>unsigned This means the host variable is of type <type>unsigned
int</type> and the field in the int</type> and the field in the
<productname>Postgres</productname> database is of another type <productname>Postgres</productname> database is of another type
and contains a value that cannot be interpreted as an and contains a value that cannot be interpreted as an
<type>unsigned int</type>. The library uses <type>unsigned int</type>. The library uses
<function>strtoul()</function> for this conversion. <function>strtoul()</function> for this conversion.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-206 (ECPG_FLOAT_FORMAT): Not correctly formatted floating point type: %s line %d.</computeroutput></term> <term><computeroutput>-206 (ECPG_FLOAT_FORMAT): Not correctly formatted floating point type: %s line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This means the host variable is of type <type>float</type> and This means the host variable is of type <type>float</type> and
the field in the <productname>Postgres</productname> database the field in the <productname>Postgres</productname> database
is of another type and contains a value that cannot be is of another type and contains a value that cannot be
interpreted as a <type>float</type>. The library uses interpreted as a <type>float</type>. The library uses
<function>strtod()</function> for this conversion. <function>strtod()</function> for this conversion.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-207 (ECPG_CONVERT_BOOL): Unable to convert %s to bool on line %d.</computeroutput></term> <term><computeroutput>-207 (ECPG_CONVERT_BOOL): Unable to convert %s to bool on line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This means the host variable is of type <type>bool</type> and This means the host variable is of type <type>bool</type> and
the field in the <productname>Postgres</productname> database the field in the <productname>Postgres</productname> database
is neither <literal>'t'</> nor <literal>'f'</>. is neither <literal>'t'</> nor <literal>'f'</>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-208 (ECPG_EMPTY): Empty query line %d.</computeroutput></term> <term><computeroutput>-208 (ECPG_EMPTY): Empty query line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
<productname>Postgres</productname> returned <symbol>PGRES_EMPTY_QUERY</symbol>, probably <productname>Postgres</productname> returned <symbol>PGRES_EMPTY_QUERY</symbol>, probably
because the query indeed was empty. because the query indeed was empty.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-209 (ECPG_MISSING_INDICATOR): NULL value without indicator in line %d.</computeroutput></term> <term><computeroutput>-209 (ECPG_MISSING_INDICATOR): NULL value without indicator in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
<productname>Postgres</productname> returned <symbol>ECPG_MISSING_INDICATOR</symbol> <productname>Postgres</productname> returned <symbol>ECPG_MISSING_INDICATOR</symbol>
because a NULL was returned and no NULL indicator variable was supplied. because a NULL was returned and no NULL indicator variable was supplied.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-210 (ECPG_NO_ARRAY): Variable is not an array in line %d.</computeroutput></term> <term><computeroutput>-210 (ECPG_NO_ARRAY): Variable is not an array in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
<productname>Postgres</productname> returned <symbol>ECPG_NO_ARRAY</symbol> <productname>Postgres</productname> returned <symbol>ECPG_NO_ARRAY</symbol>
because an ordinary variable was used in a place that requires because an ordinary variable was used in a place that requires
an array. an array.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-211 (ECPG_DATA_NOT_ARRAY): Data read from backend is not an array in line %d.</computeroutput></term> <term><computeroutput>-211 (ECPG_DATA_NOT_ARRAY): Data read from backend is not an array in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
<productname>Postgres</productname> returned <symbol>ECPG_DATA_NOT_ARRAY</symbol> <productname>Postgres</productname> returned <symbol>ECPG_DATA_NOT_ARRAY</symbol>
because the database returned an ordinary variable in a place because the database returned an ordinary variable in a place
that requires array value. that requires array value.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-220 (ECPG_NO_CONN): No such connection %s in line %d.</computeroutput></term> <term><computeroutput>-220 (ECPG_NO_CONN): No such connection %s in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The program tried to access a connection that does not exist. The program tried to access a connection that does not exist.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-221 (ECPG_NOT_CONN): Not connected in line %d.</computeroutput></term> <term><computeroutput>-221 (ECPG_NOT_CONN): Not connected in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The program tried to access a connection that does exist but is The program tried to access a connection that does exist but is
not open. not open.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-230 (ECPG_INVALID_STMT): Invalid statement name %s in line %d.</computeroutput></term> <term><computeroutput>-230 (ECPG_INVALID_STMT): Invalid statement name %s in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The statement you are trying to use has not been prepared. The statement you are trying to use has not been prepared.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-240 (ECPG_UNKNOWN_DESCRIPTOR): Descriptor %s not found in line %d.</computeroutput></term> <term><computeroutput>-240 (ECPG_UNKNOWN_DESCRIPTOR): Descriptor %s not found in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The descriptor specified was not foundstatement you are trying to use has not been prepared. The descriptor specified was not foundstatement you are trying to use has not been prepared.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-241 (ECPG_INVALID_DESCRIPTOR_INDEX): Descriptor index out of range in line %d.</computeroutput></term> <term><computeroutput>-241 (ECPG_INVALID_DESCRIPTOR_INDEX): Descriptor index out of range in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The descriptor index specified was out of range. The descriptor index specified was out of range.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-242 (ECPG_UNKNOWN_DESCRIPTOR_ITEM): Descriptor %s not found in line %d.</computeroutput></term> <term><computeroutput>-242 (ECPG_UNKNOWN_DESCRIPTOR_ITEM): Descriptor %s not found in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The descriptor specified was not foundstatement you are trying to use has not been prepared. The descriptor specified was not foundstatement you are trying to use has not been prepared.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-243 (ECPG_VAR_NOT_NUMERIC): Variable is not a numeric type in line %d.</computeroutput></term> <term><computeroutput>-243 (ECPG_VAR_NOT_NUMERIC): Variable is not a numeric type in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The database returned a numeric value and the variable was not The database returned a numeric value and the variable was not
numeric. numeric.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-244 (ECPG_VAR_NOT_CHAR): Variable is not a character type in line %d.</computeroutput></term> <term><computeroutput>-244 (ECPG_VAR_NOT_CHAR): Variable is not a character type in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The database returned a non-numeric value and the variable was The database returned a non-numeric value and the variable was
numeric. numeric.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-400 (ECPG_PGSQL): Postgres error: %s line %d.</computeroutput></term> <term><computeroutput>-400 (ECPG_PGSQL): Postgres error: %s line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
Some <productname>Postgres</productname> error. Some <productname>Postgres</productname> error.
The message contains the error message from the The message contains the error message from the
<productname>Postgres</productname> backend. <productname>Postgres</productname> backend.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-401 (ECPG_TRANS): Error in transaction processing line %d.</computeroutput></term> <term><computeroutput>-401 (ECPG_TRANS): Error in transaction processing line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
<productname>Postgres</productname> signaled that we cannot start, <productname>Postgres</productname> signaled that we cannot start,
commit or rollback the transaction. commit or rollback the transaction.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>-402 (ECPG_CONNECT): Could not connect to database %s in line %d.</computeroutput></term> <term><computeroutput>-402 (ECPG_CONNECT): Could not connect to database %s in line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
The connect to the database did not work. The connect to the database did not work.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><computeroutput>100 (ECPG_NOT_FOUND): Data not found line %d.</computeroutput></term> <term><computeroutput>100 (ECPG_NOT_FOUND): Data not found line %d.</computeroutput></term>
<listitem> <listitem>
<para> <para>
This is a <quote>normal</quote> error that tells you that what you are querying cannot This is a <quote>normal</quote> error that tells you that what you are querying cannot
be found or you are at the end of the cursor. be found or you are at the end of the cursor.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -486,30 +486,26 @@ struct sqlca ...@@ -486,30 +486,26 @@ struct sqlca
<sect1 id="ecpg-limitations"> <sect1 id="ecpg-limitations">
<title>Limitations</title> <title>Limitations</title>
<abstract>
<para>
What will never be included and why it cannot be done.
</para>
</abstract>
<para> <para>
What will never be included and why it cannot be done:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term>Oracle's single tasking</term> <term>Oracle's single tasking</term>
<listitem> <listitem>
<para> <para>
Oracle version 7.0 on <systemitem class="osname">AIX</> 3 uses OS-supported locks in shared Oracle version 7.0 on <systemitem class="osname">AIX</> 3 uses OS-supported locks in shared
memory that allow an application designer to link an application memory that allow an application designer to link an application
in a <quote>single tasking</quote> way. Instead of starting one client in a <quote>single tasking</quote> way. Instead of starting one client
process per application process, both the database part and the process per application process, both the database part and the
application part run in the same process. In later versions of application part run in the same process. In later versions of
Oracle this is no longer supported. Oracle this is no longer supported.
</para> </para>
<para> <para>
This would require a total redesign of the This would require a total redesign of the
<productname>Postgres</productname> access model and the <productname>Postgres</productname> access model and the
performance gain does not justify the effort. performance gain does not justify the effort.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -545,15 +541,15 @@ struct sqlca ...@@ -545,15 +541,15 @@ struct sqlca
<term>Syntax of FETCH</term> <term>Syntax of FETCH</term>
<listitem> <listitem>
<para> <para>
The standard syntax for FETCH is: The standard syntax for FETCH is:
</para> </para>
<para> <para>
FETCH [direction] [amount] IN|FROM <replaceable>cursor</replaceable>. FETCH [direction] [amount] IN|FROM <replaceable>cursor</replaceable>.
</para> </para>
<para> <para>
<application>ORACLE</application>, however, does not use the keywords IN <application>ORACLE</application>, however, does not use the keywords IN
or FROM. This feature cannot be added since it would create parsing or FROM. This feature cannot be added since it would create parsing
conflicts. conflicts.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -580,77 +576,74 @@ struct sqlca ...@@ -580,77 +576,74 @@ struct sqlca
<varlistentry> <varlistentry>
<term>Library functions</term> <term>Library functions</term>
<listitem> <listitem>
<para> <para>
to_date et al. does not exist. However, to_date et al. does not exist. However,
<productname>Postgres</productname> has some good conversion <productname>Postgres</productname> has some good conversion
routines so you probably won't miss them. routines so you probably won't miss them.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Structures and unions</term> <term>Structures and unions</term>
<listitem> <listitem>
<para> <para>
Structures and unions have to be defined in the Structures and unions have to be defined in the
<command>declare</> section. <command>declare</> section.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Missing statements</term> <term>Missing statements</term>
<listitem> <listitem>
<para> <para>
The following statements are not implemented thus far: The following statements are not implemented thus far:
<variablelist>
<varlistentry> <itemizedlist>
<term><literal>exec sql allocate</></term> <listitem>
<listitem> <para>
<para> <literal>exec sql allocate</>
</para> </para>
</listitem> </listitem>
</varlistentry>
<varlistentry> <listitem>
<term><literal>exec sql deallocate</></term> <para>
<listitem> <literal>exec sql deallocate</></term>
<para> </para>
</para> </listitem>
</listitem>
</varlistentry> <listitem>
<varlistentry> <para>
<term><literal>SQLSTATE</></term> <literal>SQLSTATE</></term>
<listitem> </para>
<para> </listitem>
</para> </itemizedlist>
</listitem> </para>
</varlistentry>
</variablelist>
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>message 'no data found'</term> <term>message 'no data found'</term>
<listitem> <listitem>
<para> <para>
The error message for <quote>no data</quote> in: The error message for <quote>no data</quote> in:
<programlisting> <programlisting>
exec sql insert select from statement exec sql insert select from statement
</programlisting> </programlisting>
has to be <literal>100</>. has to be <literal>100</>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><literal>sqlwarn[6]</literal></term> <term><literal>sqlwarn[6]</literal></term>
<listitem> <listitem>
<para> <para>
<literal>sqlwarn[6]</literal> should be <literal>W</> if the <command>PRECISION</> <literal>sqlwarn[6]</literal> should be <literal>W</> if the <command>PRECISION</>
or <command>SCALE</> value specified in a <command>SET or <command>SCALE</> value specified in a <command>SET
DESCRIPTOR</> statement was ignored. DESCRIPTOR</> statement was ignored.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
...@@ -680,269 +673,341 @@ exec sql insert select from statement ...@@ -680,269 +673,341 @@ exec sql insert select from statement
<varlistentry> <varlistentry>
<term>Declare sections</term> <term>Declare sections</term>
<listitem> <listitem>
<para> <para>
<command>Declare</> sections begin with: <command>Declare</> sections begin with:
<programlisting> <programlisting>
exec sql begin declare section; exec sql begin declare section;
</programlisting> </programlisting>
and end with: and end with:
<programlisting> <programlisting>
exec sql end declare section; exec sql end declare section;
</programlisting> </programlisting>
In this section only variable declarations are allowed. Every In this section only variable declarations are allowed. Every
variable declared within this section is stored in a list variable declared within this section is stored in a list
of variables indexed by name together with its corresponding of variables indexed by name together with its corresponding
type. type.
</para> </para>
<para> <para>
In particular the definition of a structure or union also must In particular the definition of a structure or union also must
be listed inside a <command>declare</> section. Otherwise be listed inside a <command>declare</> section. Otherwise
<application>ecpg</application> cannot handle these types since <application>ecpg</application> cannot handle these types since
it does not know the definition. it does not know the definition.
</para> </para>
<para> <para>
The declaration is also echoed to the file to make it a normal The declaration is also echoed to the file to make it a normal
C variable. C variable.
</para> </para>
<para> <para>
The special types <type>VARCHAR</type> and <type>VARCHAR2</type> are converted into a named struct The special types <type>VARCHAR</type> and <type>VARCHAR2</type> are converted into a named struct
for every variable. A declaration like: for every variable. A declaration like:
<programlisting> <programlisting>
VARCHAR var[180]; VARCHAR var[180];
</programlisting> </programlisting>
is converted into: is converted into:
<programlisting> <programlisting>
struct varchar_var { int len; char arr[180]; } var; struct varchar_var { int len; char arr[180]; } var;
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Include statements</term> <term>Include statements</term>
<listitem> <listitem>
<para> <para>
An include statement looks like: An include statement looks like:
<programlisting> <programlisting>
exec sql include filename; exec sql include filename;
</programlisting> </programlisting>
Note that this is NOT the same as: Note that this is NOT the same as:
<programlisting> <programlisting>
#include &lt;filename.h&gt; #include &lt;filename.h&gt;
</programlisting> </programlisting>
</para> </para>
<para> <para>
Instead the file specified is parsed by Instead the file specified is parsed by
<application>ecpg</application> so the contents of the file are <application>ecpg</application> so the contents of the file are
included in the resulting C code. This way you are able to included in the resulting C code. This way you are able to
specify EXEC SQL commands in an include file. specify EXEC SQL commands in an include file.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Connect statement</term> <term>Connect statement</term>
<listitem> <listitem>
<para> <para>
A connect statement looks like: A connect statement looks like:
<programlisting> <programlisting>
exec sql connect to <replaceable>connection target</replaceable>; exec sql connect to <replaceable>connection target</replaceable>;
</programlisting> </programlisting>
It creates a connection to the specified database. It creates a connection to the specified database.
</para> </para>
<para> <para>
The <replaceable>connection target</replaceable> can be specified in the The <replaceable>connection target</replaceable> can be specified in the
following ways: following ways:
<variablelist> <itemizedlist>
<varlistentry> <listitem>
<term>dbname[@server][:port][as <replaceable>connection <simpara>
name</replaceable>][user <replaceable>user name</replaceable>]</term> <literal>dbname[@server][:port][as <replaceable>connection
<listitem><para></para></listitem> name</replaceable>][user <replaceable>user name</replaceable>]</literal>
</varlistentry> </simpara>
</listitem>
<varlistentry>
<term>tcp:postgresql://server[:port][/dbname][as <listitem>
<replaceable>connection name</replaceable>][user <replaceable>user name</replaceable>]</term> <simpara>
<listitem><para></para></listitem> <literal>tcp:postgresql://server[:port][/dbname][as
</varlistentry> <replaceable>connection name</replaceable>][user <replaceable>user name</replaceable>]</literal>
</simpara>
<varlistentry> </listitem>
<term>unix:postgresql://server[:port][/dbname][as
<replaceable>connection name</replaceable>][user <replaceable>user name</replaceable>]</term> <listitem>
<listitem><para></para></listitem> <simpara>
</varlistentry> <literal>unix:postgresql://server[:port][/dbname][as
<replaceable>connection name</replaceable>][user <replaceable>user name</replaceable>]</literal>
<varlistentry> </simpara>
<term><replaceable>character variable</replaceable>[as </listitem>
<replaceable>connection name</replaceable>][user <replaceable>user name</replaceable>]</term>
<listitem><para></para></listitem> <listitem>
</varlistentry> <simpara>
<literal><replaceable>character variable</replaceable>[as
<varlistentry> <replaceable>connection name</replaceable>][user <replaceable>user name</replaceable>]</literal>
<term><replaceable>character string</replaceable>[as </simpara>
<replaceable>connection name</replaceable>][<replaceable>user</replaceable>]</term> </listitem>
<listitem><para></para></listitem>
</varlistentry> <listitem>
<simpara>
<varlistentry> <literal><replaceable>character string</replaceable>[as
<term>default</term> <replaceable>connection name</replaceable>][<replaceable>user</replaceable>]</literal>
<listitem><para></para></listitem> </simpara>
</varlistentry> </listitem>
<varlistentry> <listitem>
<term>user</term> <simpara>
<listitem><para></para></listitem> <literal>default</literal>
</varlistentry> </simpara>
</variablelist> </listitem>
</para>
<listitem>
<para> <simpara>
There are also different ways to specify the user name: <literal>user</literal>
<variablelist> </simpara>
<varlistentry> </listitem>
<term><replaceable>userid</replaceable></term> </itemizedlist>
<listitem><para></para></listitem> </para>
</varlistentry>
<varlistentry> <para>
<term><replaceable>userid</replaceable>/<replaceable>password</replaceable></term> There are also different ways to specify the user name:
<listitem><para></para></listitem>
</varlistentry> <itemizedlist>
<varlistentry> <listitem>
<term><replaceable>userid</replaceable> identified by <replaceable>password</replaceable></term> <simpara>
<listitem><para></para></listitem> <literal><replaceable>userid</replaceable></literal>
</varlistentry> </simpara>
<varlistentry> </listitem>
<term><replaceable>userid</replaceable> using <replaceable>password</replaceable></term>
<listitem><para></para></listitem> <listitem>
</varlistentry> <simpara>
</variablelist> <literal><replaceable>userid</replaceable>/<replaceable>password</replaceable></literal>
</para> </simpara>
</listitem>
<para>
Finally, the <replaceable>userid</replaceable> and <replaceable>password</replaceable> may be a constant text, a <listitem>
character variable, or a character string. <simpara>
</para> <literal><replaceable>userid</replaceable> identified by <replaceable>password</replaceable></literal>
</simpara>
</listitem>
<listitem>
<simpara>
<literal><replaceable>userid</replaceable> using <replaceable>password</replaceable></literal>
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
Finally, the <replaceable>userid</replaceable> and <replaceable>password</replaceable> may be a constant text, a
character variable, or a character string.
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Disconnect statements</term> <term>Disconnect statements</term>
<listitem> <listitem>
<para> <para>
A disconnect statement looks like: A disconnect statement looks like:
<programlisting> <programlisting>
exec sql disconnect [<replaceable>connection target</replaceable>]; exec sql disconnect [<replaceable>connection target</replaceable>];
</programlisting> </programlisting>
It closes the connection to the specified database. It closes the connection to the specified database.
</para> </para>
<para> <para>
The <replaceable>connection target</replaceable> can be specified in the The <replaceable>connection target</replaceable> can be specified in the
following ways: following ways:
<variablelist>
<varlistentry> <itemizedlist>
<term><replaceable>connection name</replaceable></term> <listitem>
<listitem><para></para></listitem> <simpara>
</varlistentry> <literal><replaceable>connection name</replaceable></literal>
<varlistentry> </simpara>
<term>default</term> </listitem>
<listitem><para></para></listitem>
</varlistentry> <listitem>
<varlistentry> <simpara>
<term>current</term> <literal>default</literal>
<listitem><para></para></listitem> </simpara>
</varlistentry> </listitem>
<varlistentry>
<term>all</term> <listitem>
<listitem><para></para></listitem> <simpara>
</varlistentry> <literal>current</literal>
</variablelist> </simpara>
</para> </listitem>
<listitem>
<simpara>
<term>all</term>
</simpara>
</listitem>
</itemizedlist>
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Open cursor statement</term> <term>Open cursor statement</term>
<listitem> <listitem>
<para> <para>
An open cursor statement looks like: An open cursor statement looks like:
<programlisting> <programlisting>
exec sql open <replaceable>cursor</replaceable>; exec sql open <replaceable>cursor</replaceable>;
</programlisting> </programlisting>
and is not copied to the output. Instead, the cursor's and is not copied to the output. Instead, the cursor's
<command>DECLARE</> command is used because it opens the cursor <command>DECLARE</> command is used because it opens the cursor
as well. as well.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Commit statement</term> <term>Commit statement</term>
<listitem> <listitem>
<para> <para>
A commit statement looks like: A commit statement looks like:
<programlisting> <programlisting>
exec sql commit; exec sql commit;
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Rollback statement</term> <term>Rollback statement</term>
<listitem> <listitem>
<para> <para>
A rollback statement looks like: A rollback statement looks like:
<programlisting> <programlisting>
exec sql rollback; exec sql rollback;
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Other statements</term> <term>Other statements</term>
<listitem> <listitem>
<para> <para>
Other <acronym>SQL</acronym> statements are used by Other <acronym>SQL</acronym> statements are used by
starting with <command>exec sql</command> and ending with starting with <command>exec sql</command> and ending with
<command>;</command>. Everything in between is treated as an <command>;</command>. Everything in between is treated as an
<acronym>SQL</acronym> statement and parsed for variable <acronym>SQL</acronym> statement and parsed for variable
substitution. substitution.
</para> </para>
<para> <para>
Variable substitution occurs when a symbol starts with a colon Variable substitution occurs when a symbol starts with a colon
(<command>:</command>). The variable with that name is looked (<command>:</command>). The variable with that name is looked
up among the variables that were previously declared within a up among the variables that were previously declared within a
<command>declare</> section. Depending on whether the variable is <command>declare</> section. Depending on whether the variable is
being use for input or output, a pointer to the variable is being use for input or output, a pointer to the variable is
output to allow access by the function. output to allow access by the function.
</para> </para>
<para> <para>
For every variable that is part of the <acronym>SQL</acronym> For every variable that is part of the <acronym>SQL</acronym>
query, the function gets other arguments: query, the function gets other arguments:
<simplelist> <itemizedlist>
<member>The type as a special symbol.</member> <listitem>
<member>A pointer to the value or a pointer to the pointer.</member> <para>
<member>The size of the variable if it is a <type>char</type> or <type>varchar</type>.</member> The type as a special symbol.
<member>The number of elements in the array (for array fetches).</member> </para>
<member>The offset to the next element in the array (for array fetches).</member> </listitem>
<member>The type of the indicator variable as a special symbol.</member>
<member>A pointer to the value of the indicator variable or a pointer to the pointer of the indicator variable.</member> <listitem>
<member>0.</member> <para>
<member>Number of elements in the indicator array (for array fetches).</member> A pointer to the value or a pointer to the pointer.
<member>The offset to the next element in the indicator array </para>
(for array fetches).</member> </listitem>
</simplelist>
</para> <listitem>
<para>
The size of the variable if it is a <type>char</type> or <type>varchar</type>.
</para>
</listitem>
<listitem>
<para>
The number of elements in the array (for array fetches).
</para>
</listitem>
<listitem>
<para>
The offset to the next element in the array (for array fetches).
</para>
</listitem>
<listitem>
<para>
The type of the indicator variable as a special symbol.
</para>
</listitem>
<listitem>
<para>
A pointer to the value of the indicator variable or a pointer to the pointer of the indicator variable.
</para>
</listitem>
<listitem>
<para>
0.
</para>
</listitem>
<listitem>
<para>
Number of elements in the indicator array (for array fetches).
</para>
</listitem>
<listitem>
<para>
The offset to the next element in the indicator array (for
array fetches).
</para>
</listitem>
</itemizedlist>
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -956,16 +1021,16 @@ exec sql rollback; ...@@ -956,16 +1021,16 @@ exec sql rollback;
<para> <para>
Here is a complete example describing the output of the preprocessor of a Here is a complete example describing the output of the preprocessor of a
file <filename>foo.pgc</filename>: file <filename>foo.pgc</filename>:
<programlisting> <programlisting>
exec sql begin declare section; exec sql begin declare section;
int index; int index;
int result; int result;
exec sql end declare section; exec sql end declare section;
... ...
exec sql select res into :result from mytable where index = :index; exec sql select res into :result from mytable where index = :index;
</programlisting> </programlisting>
is translated into: is translated into:
<programlisting> <programlisting>
/* Processed by ecpg (2.6.0) */ /* Processed by ecpg (2.6.0) */
/* These two include files are added by the preprocessor */ /* These two include files are added by the preprocessor */
#include &lt;ecpgtype.h&gt;; #include &lt;ecpgtype.h&gt;;
...@@ -980,12 +1045,12 @@ exec sql select res into :result from mytable where index = :index; ...@@ -980,12 +1045,12 @@ exec sql select res into :result from mytable where index = :index;
/* exec sql end declare section */ /* exec sql end declare section */
... ...
ECPGdo(__LINE__, NULL, "select res from mytable where index = ? ", ECPGdo(__LINE__, NULL, "select res from mytable where index = ? ",
ECPGt_int,&amp;(index),1L,1L,sizeof(int), ECPGt_int,&amp;(index),1L,1L,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_int,&amp;(result),1L,1L,sizeof(int), ECPGt_int,&amp;(result),1L,1L,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 147 "foo.pgc" #line 147 "foo.pgc"
</programlisting> </programlisting>
(The indentation in this manual is added for readability and not (The indentation in this manual is added for readability and not
something the preprocessor does.) something the preprocessor does.)
</para> </para>
...@@ -1009,60 +1074,60 @@ ECPGdo(__LINE__, NULL, "select res from mytable where index = ? ", ...@@ -1009,60 +1074,60 @@ ECPGdo(__LINE__, NULL, "select res from mytable where index = ? ",
<varlistentry> <varlistentry>
<term>A line number</term> <term>A line number</term>
<listitem> <listitem>
<para> <para>
This is a line number of the original line; used in error messages only. This is a line number of the original line; used in error messages only.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>A string</term> <term>A string</term>
<listitem> <listitem>
<para> <para>
This is the <acronym>SQL</acronym> query that is to be issued. This is the <acronym>SQL</acronym> query that is to be issued.
It is modified by the input variables, i.e. the variables that It is modified by the input variables, i.e. the variables that
where not known at compile time but are to be entered in the where not known at compile time but are to be entered in the
query. Where the variables should go the string contains query. Where the variables should go the string contains
<literal>?</literal>. <literal>?</literal>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Input variables</term> <term>Input variables</term>
<listitem> <listitem>
<para> <para>
As described in the section about the preprocessor, every input variable As described in the section about the preprocessor, every input variable
gets ten arguments. gets ten arguments.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><literal>ECPGt_EOIT</literal></term> <term><literal>ECPGt_EOIT</literal></term>
<listitem> <listitem>
<para> <para>
An enum telling that there are no more input variables. An enum telling that there are no more input variables.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>Output variables</term> <term>Output variables</term>
<listitem> <listitem>
<para> <para>
As described in the section about the preprocessor, every input variable As described in the section about the preprocessor, every input variable
gets ten arguments. These variables are filled by the function. gets ten arguments. These variables are filled by the function.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>ECPGt_EORT</term> <term>ECPGt_EORT</term>
<listitem> <listitem>
<para> <para>
An enum telling that there are no more variables. An enum telling that there are no more variables.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment