📄 classodbc_1_1_prepared_statement.html.svn-base
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>odbc::PreparedStatement class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"><!-- Generated by Doxygen 1.2.13.1 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> </center><hr><h1>odbc::PreparedStatement Class Reference</h1>A prepared statement. <a href="#_details">More...</a><p><code>#include <<a class="el" href="preparedstatement_8h-source.html">preparedstatement.h</a>></code><p><p>Inheritance diagram for odbc::PreparedStatement::<p><center><img src="classodbc_1_1_prepared_statement.gif" usemap="#odbc::PreparedStatement_map" border="0"></center><map name="odbc::PreparedStatement_map"><area href="classodbc_1_1_statement.html" alt="odbc::Statement" shape="rect" coords="0,56,153,80"><area href="classodbc_1_1_error_handler.html" alt="odbc::ErrorHandler" shape="rect" coords="0,0,153,24"><area href="classodbc_1_1_callable_statement.html" alt="odbc::CallableStatement" shape="rect" coords="0,168,153,192"></map><a href="classodbc_1_1_prepared_statement-members.html">List of all members.</a><h2>Public Methods</h2><ul><li><a name="a0" doxytag="odbc::PreparedStatement::~PreparedStatement"></a>virtual <a class="el" href="classodbc_1_1_prepared_statement.html#a0">~PreparedStatement</a> ()<dl class="el"><dd><font size=-1><em>Destructor.<br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a1">clearParameters</a> ()<dl class="el"><dd><font size=-1><em>Clears the parameters.</em> <a href="#a1">More...</a><em><br><br></em></font></dl><li>bool <a class="el" href="classodbc_1_1_prepared_statement.html#a2">execute</a> ()<dl class="el"><dd><font size=-1><em>Executes this statement.</em> <a href="#a2">More...</a><em><br><br></em></font></dl><li><a name="a3" doxytag="odbc::PreparedStatement::executeQuery"></a><a class="el" href="classodbc_1_1_result_set.html">ResultSet</a> * <a class="el" href="classodbc_1_1_prepared_statement.html#a3">executeQuery</a> ()<dl class="el"><dd><font size=-1><em>Executes this statement, assuming it returns a <a class="el" href="classodbc_1_1_result_set.html">ResultSet</a>.<br><br></em></font></dl><li><a name="a4" doxytag="odbc::PreparedStatement::executeUpdate"></a>int <a class="el" href="classodbc_1_1_prepared_statement.html#a4">executeUpdate</a> ()<dl class="el"><dd><font size=-1><em>Executes this statement, assuming it returns an update count.<br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a5">setDouble</a> (int idx, double val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a double.</em> <a href="#a5">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a6">setBoolean</a> (int idx, bool val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a bool.</em> <a href="#a6">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a7">setByte</a> (int idx, signed char val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to signed char.</em> <a href="#a7">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a8">setBytes</a> (int idx, const <a class="el" href="classodbc_1_1_bytes.html">Bytes</a> &val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a chunk of bytes.</em> <a href="#a8">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a9">setDate</a> (int idx, const <a class="el" href="classodbc_1_1_date.html">Date</a> &val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a <a class="el" href="classodbc_1_1_date.html">Date</a>.</em> <a href="#a9">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a10">setFloat</a> (int idx, float val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a float.</em> <a href="#a10">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a11">setInt</a> (int idx, int val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to an int.</em> <a href="#a11">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a12">setLong</a> (int idx, Long val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a Long.</em> <a href="#a12">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a13">setShort</a> (int idx, short val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a short.</em> <a href="#a13">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a14">setString</a> (int idx, const std::string &val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a string.</em> <a href="#a14">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a15">setTime</a> (int idx, const <a class="el" href="classodbc_1_1_time.html">Time</a> &val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a <a class="el" href="classodbc_1_1_time.html">Time</a>.</em> <a href="#a15">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a16">setTimestamp</a> (int idx, const <a class="el" href="classodbc_1_1_timestamp.html">Timestamp</a> &val)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a <a class="el" href="classodbc_1_1_timestamp.html">Timestamp</a>.</em> <a href="#a16">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a17">setAsciiStream</a> (int idx, std::istream *s, int len)<dl class="el"><dd><font size=-1><em>Sets a parameter value to an ascii stream.</em> <a href="#a17">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a18">setBinaryStream</a> (int idx, std::istream *s, int len)<dl class="el"><dd><font size=-1><em>Sets a parameter value to a binary stream.</em> <a href="#a18">More...</a><em><br><br></em></font></dl><li>void <a class="el" href="classodbc_1_1_prepared_statement.html#a19">setNull</a> (int idx, int sqlType)<dl class="el"><dd><font size=-1><em>Sets a parameter value to NULL.</em> <a href="#a19">More...</a><em><br><br></em></font></dl></ul><hr><a name="_details"></a><h2>Detailed Description</h2>A prepared statement.<p>A prepared statement is precompiled by the driver and/or datasource, and can be executed multiple times with different parameters.<p>Parameters are set using the setXXX methods. Note that it's advisable to use the set method compatible with the parameter's SQL type - for example, for a <code><a class="el" href="structodbc_1_1_types.html#s19s4">Types::DATE</a></code>, <code><a class="el" href="classodbc_1_1_prepared_statement.html#a9">setDate</a>()</code> should be used. Question marks (<code>"?"</code>) are used in the SQL statement to represent a parameter, for example: <pre> <a class="el" href="classodbc_1_1_prepared_statement.html">PreparedStatement</a>* pstmt=con->prepareStatement ("INSERT INTO SOMETABLE(AN_INTEGER_COL,A_VARCHAR_COL) VALUES(?,?)"); pstmt->setInt(1,10); pstmt->setString(2,"Hello, world!"); int affectedRows=pstmt-><a class="el" href="classodbc_1_1_prepared_statement.html#a4">executeUpdate</a>(); </pre> <dl compact><dt><b>See also: </b><dd><a class="el" href="classodbc_1_1_connection.html#a18">Connection::prepareStatement</a>() </dl><p><hr><h2>Member Function Documentation</h2><a name="a1" doxytag="odbc::PreparedStatement::clearParameters"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void odbc::PreparedStatement::clearParameters </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Clears the parameters.<p>The set of parameters stays around until they are set again. To explicitly clear them (and thus release buffers held by the driver), this method should be called. </td> </tr></table><a name="a2" doxytag="odbc::PreparedStatement::execute"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool odbc::PreparedStatement::execute </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Executes this statement.<p><dl compact><dt><b>Returns: </b><dd>True if the result is a <a class="el" href="classodbc_1_1_result_set.html">ResultSet</a>, false if it's an update count or unknown. </dl> </td> </tr></table><a name="a17" doxytag="odbc::PreparedStatement::setAsciiStream"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void odbc::PreparedStatement::setAsciiStream </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname" nowrap> <em>idx</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>std::istream * </td> <td class="mdname" nowrap> <em>s</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>len</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Sets a parameter value to an ascii stream.<p><dl compact><dt><b>Parameters: </b><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>idx</em> </td><td>The parameter index, starting at 1 </td></tr><tr><td valign=top><em>s</em> </td><td>The stream to assign </td></tr><tr><td valign=top><em>len</em> </td><td>The number of bytes available in the stream </td></tr></table></dl> </td> </tr></table><a name="a18" doxytag="odbc::PreparedStatement::setBinaryStream"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void odbc::PreparedStatement::setBinaryStream </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname" nowrap> <em>idx</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>std::istream * </td> <td class="mdname" nowrap> <em>s</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>len</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Sets a parameter value to a binary stream.<p><dl compact><dt><b>Parameters: </b><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>idx</em> </td><td>The parameter index, starting at 1 </td></tr><tr><td valign=top><em>s</em> </td><td>The stream to assign </td></tr><tr><td valign=top><em>len</em> </td><td>The number of bytes available in the stream </td></tr></table></dl> </td> </tr></table><a name="a6" doxytag="odbc::PreparedStatement::setBoolean"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void odbc::PreparedStatement::setBoolean </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname" nowrap> <em>idx</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>bool </td> <td class="mdname" nowrap> <em>val</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Sets a parameter value to a bool.<p><dl compact><dt><b>Parameters: </b><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>idx</em> </td><td>The parameter index, starting at 1 </td></tr><tr><td valign=top><em>val</em> </td><td>The value to set </td></tr></table></dl> </td> </tr></table><a name="a7" doxytag="odbc::PreparedStatement::setByte"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -