odbc.html

来自「perl教程」· HTML 代码 · 共 822 行 · 第 1/2 页

HTML
822
字号
<p>Returns an array of fieldnames found in the current data set. There is
no guarantee on order.</p>
</dd>
</li>
<dt><strong><a name="item_getconnections">GetConnections ()</a></strong>

<dd>
<p>Returns an array of connection numbers showing what connections are
currently open.</p>
</dd>
</li>
<dt><strong><a name="item_getconnectoption">GetConnectOption ( OPTION )</a></strong>

<dd>
<p>Returns the value of the specified connect option <code>OPTION</code>. Refer to
ODBC documentation for more information on the options and values.</p>
</dd>
<dd>
<p>Returns a string or scalar depending upon the option specified.</p>
</dd>
</li>
<dt><strong><a name="item_getcursorname">GetCursorName ()</a></strong>

<dd>
<p>Returns the name of the current cursor as a string or <em>undef</em>.</p>
</dd>
</li>
<dt><strong><a name="item_getdata">GetData ()</a></strong>

<dd>
<p>Retrieves the current row from the dataset. This is not generally
used by users; it is used internally.</p>
</dd>
<dd>
<p>Returns an array of field data where the first element is either
<em>false</em> (if successful) and <em>true</em> (if <strong>not</strong> successful).</p>
</dd>
</li>
<dt><strong><a name="item_getdsn">getDSN ( [ DSN ] )</a></strong>

<dd>
<p>Returns an associative array indicating the configuration for the
specified DSN.</p>
</dd>
<dd>
<p>If no DSN is specified then the current connection is used.</p>
</dd>
<dd>
<p>The returned associative array consists of:</p>
</dd>
<dd>
<pre>
    <span class="keyword">keys</span><span class="operator">=</span><span class="variable">DSN</span> <span class="variable">keyword</span><span class="operator">;</span> <span class="keyword">values</span><span class="operator">=</span><span class="variable">Keyword</span> <span class="variable">value</span><span class="operator">.</span> <span class="variable">$Data</span><span class="operator">{</span><span class="variable">$Keyword</span><span class="operator">}</span><span class="operator">=</span><span class="variable">Value</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_getfunctions">GetFunctions ( [ FUNCTION1, FUNCTION2, ... ] )</a></strong>

<dd>
<p>Returns an associative array indicating the ability of the ODBC Driver
to support the specified functions. If no functions are specified,
then a 100 element associative array is returned containing all
possible functions and their values.</p>
</dd>
<dd>
<p><code>FUNCTION</code> must be in the form of an ODBC API constant like
<code>SQL_API_SQLTRANSACT</code>.</p>
</dd>
<dd>
<p>The returned array will contain the results like:</p>
</dd>
<dd>
<pre>
    <span class="variable">$Results</span><span class="operator">{</span><span class="string">SQL_API_SQLTRANSACT</span><span class="operator">}</span><span class="operator">=</span><span class="variable">Value</span>
</pre>
</dd>
<dd>
<p>Example:</p>
</dd>
<dd>
<pre>
    <span class="variable">$Results</span> <span class="operator">=</span> <span class="variable">$O</span><span class="operator">-&gt;</span><span class="variable">GetFunctions</span><span class="operator">(</span>
                                <span class="variable">$O</span><span class="operator">-&gt;</span><span class="variable">SQL_API_SQLTRANSACT</span><span class="operator">,</span>
                                <span class="variable">SQL_API_SQLSETCONNECTOPTION</span>
                               <span class="operator">);</span>
    <span class="variable">$ConnectOption</span> <span class="operator">=</span> <span class="variable">$Results</span><span class="operator">{</span><span class="string">SQL_API_SQLSETCONNECTOPTION</span><span class="operator">}</span><span class="operator">;</span>
    <span class="variable">$Transact</span> <span class="operator">=</span> <span class="variable">$Results</span><span class="operator">{</span><span class="string">SQL_API_SQLTRANSACT</span><span class="operator">}</span><span class="operator">;</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_getinfo">GetInfo ( OPTION )</a></strong>

<dd>
<p>Returns a string indicating the value of the particular
option specified.</p>
</dd>
</li>
<dt><strong><a name="item_getmaxbufsize">GetMaxBufSize ()</a></strong>

<dd>
<p>Returns the current allocated limit for <em>MaxBufSize</em>. For more info,
see <a href="#item_setmaxbufsize"><code>SetMaxBufSize</code></a>.</p>
</dd>
</li>
<dt><strong><a name="item_getsqlstate">GetSQLState () *</a></strong>

<dd>
<p>Returns a string indicating the SQL state as reported by ODBC. The SQL
state is a code that the ODBC Manager or ODBC Driver returns after the
execution of a SQL function. This is helpful for debugging purposes.</p>
</dd>
</li>
<dt><strong><a name="item_getstmtclosetype">GetStmtCloseType ( [ CONNECTION ] )</a></strong>

<dd>
<p>Returns a string indicating the type of closure that will be used
everytime the <em>hstmt</em> is freed. See <a href="#item_setstmtclosetype"><code>SetStmtCloseType</code></a> for details.</p>
</dd>
<dd>
<p>By default, the connection of the current object will be used. If
<code>CONNECTION</code> is a valid connection number, then it will be used.</p>
</dd>
</li>
<dt><strong><a name="item_getstmtoption">GetStmtOption ( OPTION )</a></strong>

<dd>
<p>Returns the value of the specified statement option <code>OPTION</code>. Refer
to ODBC documentation for more information on the options and values.</p>
</dd>
<dd>
<p>Returns a string or scalar depending upon the option specified.</p>
</dd>
</li>
<dt><strong><a name="item_moreresults">MoreResults ()</a></strong>

<dd>
<p>This will report whether there is data yet to be retrieved from the
query. This can happen if the query was a multiple select.</p>
</dd>
<dd>
<p>Example:</p>
</dd>
<dd>
<pre>
    &quot;SELECT * FROM [foo] SELECT * FROM [bar]&quot;</pre>
</dd>
<dd>
<p><strong>NOTE</strong>: Not all drivers support this.</p>
</dd>
<dd>
<p>Returns <em>1</em> if there is more data, <em>undef</em> otherwise.</p>
</dd>
</li>
<dt><strong><a name="item_rowcount">RowCount ( CONNECTION )</a></strong>

<dd>
<p>For <em>UPDATE</em>, <em>INSERT</em> and <em>DELETE</em> statements, the returned value
is the number of rows affected by the request or <em>-1</em> if the number
of affected rows is not available.</p>
</dd>
<dd>
<p><strong>NOTE 1</strong>: This function is not supported by all ODBC drivers! Some
drivers do support this but not for all statements (e.g., it is
supported for <em>UPDATE</em>, <em>INSERT</em> and <em>DELETE</em> commands but not for
the <em>SELECT</em> command).</p>
</dd>
<dd>
<p><strong>NOTE 2</strong>: Many data sources cannot return the number of rows in a
result set before fetching them; for maximum interoperability,
applications should not rely on this behavior.</p>
</dd>
<dd>
<p>Returns the number of affected rows, or <em>-1</em> if not supported by the
driver in the current context.</p>
</dd>
</li>
<dt><strong><a name="item_run">Run ( SQL )</a></strong>

<dd>
<p>Executes the SQL command <strong>SQL</strong> and dumps to the screen info about
it. Used primarily for debugging.</p>
</dd>
<dd>
<p>No return value.</p>
</dd>
</li>
<dt><strong><a name="item_setconnectoption">SetConnectOption ( OPTION ) *</a></strong>

<dd>
<p>Sets the value of the specified connect option <strong>OPTION</strong>. Refer to
ODBC documentation for more information on the options and values.</p>
</dd>
<dd>
<p>Returns <em>true</em> on success, <em>false</em> otherwise.</p>
</dd>
</li>
<dt><strong><a name="item_setcursorname">SetCursorName ( NAME ) *</a></strong>

<dd>
<p>Sets the name of the current cursor.</p>
</dd>
<dd>
<p>Returns <em>true</em> on success, <em>false</em> otherwise.</p>
</dd>
</li>
<dt><strong><a name="item_setpos">SetPos ( ROW [, OPTION, LOCK ] ) *</a></strong>

<dd>
<p>Moves the cursor to the row <code>ROW</code> within the current keyset (<strong>not</strong>
the current data/result set).</p>
</dd>
<dd>
<p>Returns <em>true</em> on success, <em>false</em> otherwise.</p>
</dd>
</li>
<dt><strong><a name="item_setmaxbufsize">SetMaxBufSize ( SIZE )</a></strong>

<dd>
<p>This sets the <em>MaxBufSize</em> for a particular connection. This will
most likely never be needed but...</p>
</dd>
<dd>
<p>The amount of memory that is allocated to retrieve the field data of a
record is dynamic and changes when it need to be larger. I found that
a memo field in an MS Access database ended up requesting 4 Gig of
space. This was a bit much so there is an imposed limit (2,147,483,647
bytes) that can be allocated for data retrieval.</p>
</dd>
<dd>
<p>Since it is possible that someone has a database with field data
greater than 10,240, you can use this function to increase the limit
up to a ceiling of 2,147,483,647 (recompile if you need more).</p>
</dd>
<dd>
<p>Returns the max number of bytes.</p>
</dd>
</li>
<dt><strong><a name="item_setstmtclosetype">SetStmtCloseType ( TYPE [, CONNECTION ] )</a></strong>

<dd>
<p>Sets a particular <em>hstmt</em> close type for the connection. This is the
same as <code>ODBCFreeStmt(hstmt, TYPE)</code>. By default, the connection of
the current object will be used. If <code>CONNECTION</code> is a valid
connection number, then it will be used.</p>
</dd>
<dd>
<p><code>TYPE</code> may be one of:</p>
</dd>
<dd>
<pre>
    SQL_CLOSE
    SQL_DROP
    SQL_UNBIND
    SQL_RESET_PARAMS</pre>
</dd>
<dd>
<p>Returns a string indicating the newly set type.</p>
</dd>
</li>
<dt><strong><a name="item_setstmtoption">SetStmtOption ( OPTION ) *</a></strong>

<dd>
<p>Sets the value of the specified statement option <code>OPTION</code>. Refer to
ODBC documentation for more information on the options and values.</p>
</dd>
<dd>
<p>Returns <em>true</em> on success, <em>false</em> otherwise.</p>
</dd>
</li>
<dt><strong><a name="item_shutdown">ShutDown ()</a></strong>

<dd>
<p>Closes the ODBC connection and dumps to the screen info about
it. Used primarily for debugging.</p>
</dd>
<dd>
<p>No return value.</p>
</dd>
</li>
<dt><strong><a name="item_sql">Sql ( SQL_STRING )</a></strong>

<dd>
<p>Executes the SQL command <code>SQL_STRING</code> on the current connection.</p>
</dd>
<dd>
<p>Returns <em>?</em> on success, or an error number on failure.</p>
</dd>
</li>
<dt><strong><a name="item_tablelist">TableList ( QUALIFIER, OWNER, NAME, TYPE )</a></strong>

<dd>
<p>Returns the catalog of tables that are available in the DSN. For an
unknown parameter, just specify the empty string <em>&quot;&quot;</em>.</p>
</dd>
<dd>
<p>Returns an array of table names.</p>
</dd>
</li>
<dt><strong><a name="item_transact">Transact ( TYPE ) *</a></strong>

<dd>
<p>Forces the ODBC connection to perform a <em>rollback</em> or <em>commit</em>
transaction.</p>
</dd>
<dd>
<p><code>TYPE</code> may be one of:</p>
</dd>
<dd>
<pre>
    SQL_COMMIT
    SQL_ROLLBACK</pre>
</dd>
<dd>
<p><strong>NOTE</strong>: This only works with ODBC drivers that support transactions.
Your driver supports it if <em>true</em> is returned from:</p>
</dd>
<dd>
<pre>
    $O-&gt;GetFunctions($O-&gt;SQL_API_SQLTRANSACT)[1]</pre>
</dd>
<dd>
<p>(See <a href="#item_getfunctions"><code>GetFunctions</code></a> for more details.)</p>
</dd>
<dd>
<p>Returns <em>true</em> on success, <em>false</em> otherwise.</p>
</dd>
</li>
<dt><strong><a name="item_version">Version ( PACKAGES )</a></strong>

<dd>
<p>Returns an array of version numbers for the requested packages
(<em>ODBC.pm</em> or <em>ODBC.PLL</em>). If the list <code>PACKAGES</code> is empty, then
all version numbers are returned.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="limitations">LIMITATIONS</a></h1>
<p>What known problems does this thing have?</p>
<ul>
<li>
<p>If the account under which the process runs does not have write
permission on the default directory (for the process, not the ODBC
DSN), you will probably get a runtime error during a
<code>SQLConnection</code>. I don't think that this is a problem with the code,
but more like a problem with ODBC. This happens because some ODBC
drivers need to write a temporary file. I noticed this using the MS
Jet Engine (Access Driver).</p>
</li>
<li>
<p>This module has been neither optimized for speed nor optimized for
memory consumption.</p>
</li>
</ul>
<p>
</p>
<hr />
<h1><a name="installation_notes">INSTALLATION NOTES</a></h1>
<p>If you wish to use this module with a build of Perl other than
ActivePerl, you may wish to fetch the original source distribution for
this module at:</p>
<pre>
  <a href="ftp://ftp.roth.net:/pub/ntperl/ODBC/970208/Bin/Win32_ODBC_Build_CORE.zip">ftp://ftp.roth.net:/pub/ntperl/ODBC/970208/Bin/Win32_ODBC_Build_CORE.zip</a></pre>
<p>or one of the other archives at that same location. See the included
README for hints on installing this module manually, what to do if you
get a <em>parse exception</em>, and a pointer to a test script for this
module.</p>
<p>
</p>
<hr />
<h1><a name="other_documentation">OTHER DOCUMENTATION</a></h1>
<p>Find a FAQ for Win32::ODBC at:</p>
<pre>
  <a href="http://www.roth.net/odbc/odbcfaq.htm">http://www.roth.net/odbc/odbcfaq.htm</a></pre>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Dave Roth &lt;<a href="mailto:rothd@roth.net">rothd@roth.net</a>&gt;</p>
<p>
</p>
<hr />
<h1><a name="credits">CREDITS</a></h1>
<p>Based on original code by Dan DeMaggio &lt;<a href="mailto:dmag@umich.edu">dmag@umich.edu</a>&gt;</p>
<p>
</p>
<hr />
<h1><a name="disclaimer">DISCLAIMER</a></h1>
<p>I do not guarantee <strong>ANYTHING</strong> with this package. If you use it you
are doing so <strong>AT YOUR OWN RISK</strong>! I may or may not support this
depending on my time schedule.</p>
<p>
</p>
<hr />
<h1><a name="history">HISTORY</a></h1>
<p>Last Modified 1999.09.25.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 1996-1998 Dave Roth. All rights reserved.</p>
<p>Courtesy of Roth Consulting:  <a href="http://www.roth.net/consult/">http://www.roth.net/consult/</a></p>
<p>Use under GNU General Public License. Details can be found at:
<a href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a></p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?