92 lines
4.1 KiB
HTML
92 lines
4.1 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="Execute ODBC functions" />
|
|
<meta name="abstract" content="Use these handle types to execute ODBC functions." />
|
|
<meta name="description" content="Use these handle types to execute ODBC functions." />
|
|
<meta name="DC.Relation" scheme="URI" content="rzaikodbcapiinfo.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="executeodbcfunct" />
|
|
<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>Execute ODBC functions</title>
|
|
</head>
|
|
<body id="executeodbcfunct"><a name="executeodbcfunct"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Execute ODBC functions</h1>
|
|
<div><p>Use these handle types to execute ODBC functions.</p>
|
|
<div class="section"> <dl><dt class="dlterm">SQLAllocHandle with SQL_HANDLE_STMT as the handle type</dt>
|
|
<dd> <ul><li>Allocates memory for information about an <span class="keyword">SQL</span> statement.
|
|
<ul><li>Application must request a statement handle prior to submitting <span class="keyword">SQL</span> statements.</li>
|
|
<li>Variable type HSTMT. <p>In C, this statement is coded: </p>
|
|
<pre>HSTMT hstmt;
|
|
|
|
rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);</pre>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="dlterm">SQLExecDirect</dt>
|
|
<dd> <ul><li>Executes a preparable statement.</li>
|
|
<li>Fastest way to submit an <span class="keyword">SQL</span> string
|
|
for one time execution.</li>
|
|
<li>If rc is not equal to SQL_SUCCESS, the SQLGetDiagRec API can be used to
|
|
find the cause of the error condition. <p>In C, this statement is coded: </p>
|
|
<pre>SQLCHAR stmt[ ] = "CREATE TABLE NAMEID (ID INTEGER, NAME VARCHAR(50))";
|
|
|
|
rc = SQLExecDirect(hstmt, stmt, SQL_NTS);</pre>
|
|
</li>
|
|
<li>Return code <ul><li>SQL_SUCCESS</li>
|
|
<li>SQL_SUCCESS_WITH_INFO</li>
|
|
<li>SQL_ERROR</li>
|
|
<li>SQL_INVALID_HANDLE</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="dlterm">SQLGetDiagRec</dt>
|
|
<dd>To retrieve error information for an error on a statement: <p>In C, this
|
|
statement is coded: </p>
|
|
<pre>SQLSMALLINT i = 1, cbErrorMsg ;
|
|
SQLCHAR szSQLState[6], szErrorMsg[SQL_MAX_MESSAGE_LENGTH];
|
|
SQLINTEGER nativeError;
|
|
|
|
rc = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, szSQLState, &nativeError, szErrorMsg,
|
|
SQL_MAX_MESSAGE_LENGTH, &cbErrorMsg);</pre>
|
|
<ul><li><strong>szSQLState</strong> <ul><li>5 character string</li>
|
|
<li>00000 = success</li>
|
|
<li>01004 = data truncated</li>
|
|
<li>07001 = wrong number of parameters <div class="note"><span class="notetitle">Note:</span> The previous items are only several
|
|
of many possible SQL states.</div>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><strong>fNativeError</strong> - specific to data source</li>
|
|
<li><strong>szErrorMsg</strong> - Error Message text</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaikodbcapiinfo.htm" title="Identify the files required to build an ODBC application.">Files required to build an ODBC application</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |