@@ -156,6 +156,48 @@ proc getDBs { {host "localhost"} {port "5432"} } {
156156 </example>
157157</Sect1>
158158
159+ <Sect1 id="libpgtcl-loading">
160+ <Title>Loading <application>pgtcl</application> into your application</Title>
161+
162+ <para>
163+ Before using <application>pgtcl</application> commands, you must load
164+ <filename>libpgtcl</> into your Tcl application. This is normally
165+ done with the Tcl <literal>load</> command. Here is an example:
166+
167+ <programlisting>
168+ load libpgtcl[info sharedlibextension]
169+ </programlisting>
170+
171+ The use of <literal>info sharedlibextension</> is recommended in
172+ preference to hard-wiring <literal>.so</> or <literal>.sl</> into
173+ the program.
174+ </para>
175+
176+ <para>
177+ The <literal>load</> command will fail unless the system's dynamic loader
178+ knows where to look for the <filename>libpgtcl</> shared library file.
179+ You may need to work with <literal>ldconfig</>, or set the environment
180+ variable <envar>LD_LIBRARY_PATH</>, or use some equivalent facility for
181+ your platform to make it work.
182+ </para>
183+
184+ <para>
185+ <filename>libpgtcl</> in turn depends on <filename>libpq</>, so the
186+ dynamic loader must also be able to find the <filename>libpq</> shared
187+ library. In practice this is seldom an issue, since both of these
188+ shared libraries are normally stored in the same directory, but it
189+ can be a stumbling block in some configurations.
190+ </para>
191+
192+ <para>
193+ If you use a custom executable for your application, you might choose
194+ to statically bind <filename>libpgtcl</> into the executable and thereby
195+ avoid the <literal>load</> command and the potential problems of dynamic
196+ linking. See the source code for <application>pgtclsh</> for an example.
197+ </para>
198+
199+ </Sect1>
200+
159201<Sect1 id="libpgtcl-ref">
160202<Title><application>pgtcl</application> Command Reference Information</Title>
161203
@@ -817,8 +859,7 @@ loop over the result of a SELECT statement
817859<DATE>1997-12-24</DATE>
818860</REFSYNOPSISDIVINFO>
819861<SYNOPSIS>
820- pg_select <REPLACEABLE CLASS="PARAMETER">dbHandle</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">queryString</REPLACEABLE>
821- <REPLACEABLE CLASS="PARAMETER">arrayVar</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">queryProcedure</REPLACEABLE>
862+ pg_select <REPLACEABLE CLASS="PARAMETER">dbHandle</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">queryString</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">arrayVar</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">queryProcedure</REPLACEABLE>
822863</SYNOPSIS>
823864
824865<REFSECT2 ID="R2-PGTCL-PGSELECT-1">
@@ -874,18 +915,9 @@ pg_select <REPLACEABLE CLASS="PARAMETER">dbHandle</REPLACEABLE> <REPLACEABLE CLA
874915</REFSECT2INFO>
875916<TITLE>Outputs
876917</TITLE>
877- <VARIABLELIST>
878- <VARLISTENTRY>
879- <TERM>
880- <REPLACEABLE CLASS="PARAMETER">resultHandle</REPLACEABLE>
881- </TERM>
882- <LISTITEM>
883- <PARA>
884- the return result is either an error message or a handle for a query result.
885- </PARA>
886- </LISTITEM>
887- </VARLISTENTRY>
888- </VARIABLELIST>
918+ <Para>
919+ None.
920+ </Para>
889921</REFSECT2></REFSYNOPSISDIV>
890922
891923<REFSECT1 ID="R1-PGTCL-PGSELECT-1">
@@ -908,6 +940,37 @@ given chunk of code for each tuple in the result.
908940 <REPLACEABLE CLASS="PARAMETER">queryProcedure</REPLACEABLE>
909941 is executed.
910942</PARA>
943+
944+ <PARA>
945+ In addition to the field values, the following special entries are
946+ made in the array:
947+
948+ <VARIABLELIST>
949+ <VARLISTENTRY>
950+ <TERM><literal>.headers</></TERM>
951+ <LISTITEM>
952+ <PARA>A list of the column names returned by the SELECT.
953+ </PARA>
954+ </LISTITEM>
955+ </VARLISTENTRY>
956+ <VARLISTENTRY>
957+ <TERM><literal>.numcols</></TERM>
958+ <LISTITEM>
959+ <PARA>The number of columns returned by the SELECT.
960+ </PARA>
961+ </LISTITEM>
962+ </VARLISTENTRY>
963+ <VARLISTENTRY>
964+ <TERM><literal>.tupno</></TERM>
965+ <LISTITEM>
966+ <PARA>The current tuple number, starting at zero and incrementing
967+ for each iteration of the loop body.
968+ </PARA>
969+ </LISTITEM>
970+ </VARLISTENTRY>
971+ </VARIABLELIST>
972+ </PARA>
973+
911974</REFSECT1>
912975
913976<REFSECT1 ID="R1-PGTCL-PGSELECT-2">
@@ -918,7 +981,7 @@ This would work if table <classname>table</> has fields <structfield>control</>
918981(and, perhaps, other fields):
919982<ProgramListing>
920983pg_select $pgconn "SELECT * FROM table" array {
921- puts [format "%5d %s" array(control) array(name)]
984+ puts [format "%5d %s"$ array(control)$ array(name)]
922985}
923986</ProgramListing>
924987</PARA>