73 lines
3.6 KiB
HTML
73 lines
3.6 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Example: Query tool A" />
|
||
|
<meta name="abstract" content="This example illustrates using ODBC bound columns to retrieve information faster." />
|
||
|
<meta name="description" content="This example illustrates using ODBC bound columns to retrieve information faster." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzaiktoolsbadperf.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="odbcquerytoola" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Example: Query tool A</title>
|
||
|
</head>
|
||
|
<body id="odbcquerytoola"><a name="odbcquerytoola"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example: Query tool A</h1>
|
||
|
<div><p>This example illustrates using ODBC bound columns to retrieve information
|
||
|
faster.</p>
|
||
|
<div class="section"><p>Query Tool A makes the following ODBC calls to process SELECT
|
||
|
statements: </p>
|
||
|
<pre> SQLExecDirect("SELECT * FROM table_name")
|
||
|
|
||
|
WHILE there_are_rows_to_fetch DO
|
||
|
|
||
|
SQLFetch()
|
||
|
FOR every_column DO
|
||
|
SQLGetData( COLn )
|
||
|
END FOR
|
||
|
...process the data
|
||
|
|
||
|
END WHILE</pre>
|
||
|
</div>
|
||
|
<div class="section"><p>This tool does not make use of ODBC bound columns, which can help
|
||
|
performance. A faster way to process this is as follows: </p>
|
||
|
<pre> SQLExecDirect("SELECT * FROM table_name")
|
||
|
FOR every_column DO
|
||
|
SQLBindColumn( COLn )
|
||
|
END FOR
|
||
|
|
||
|
WHILE there_are_rows_to_fetch DO
|
||
|
SQLFetch()
|
||
|
...process the data
|
||
|
END WHILE</pre>
|
||
|
</div>
|
||
|
<div class="section"><p>If a table contained one column, there would be little difference
|
||
|
between the two approaches. But for a table with a 100 columns, you end up
|
||
|
with 100 times as many ODBC calls in the first example, <em>for every row fetched</em>.
|
||
|
You also can optimize the second scenario because the target data types specified
|
||
|
by the tool will not change from one FETCH to the next, like they could change
|
||
|
with each <strong>SQLGetData</strong> call.</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaiktoolsbadperf.htm" title="The following examples demonstrate performance problems that are associated with writing SQL and ODBC calls that do NOT take advantage of a unique feature of a particular ODBC driver or the server database management system.">Examples: Common tool behaviors that degrade ODBC performance</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|