📄 cstatement.html
字号:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<H1>Class CStatement
<HR>
</H1>
<P>There are some ways to use CStatement object:
<UL>
<LI>A CStatement object is used for executing a static SQL statement and
obtaining the results produced by it. <BR>
<LI>A SQL statement is pre-compiled and stored in a CStatement object. This
object can then be used to efficiently execute this statement multiple times.
</LI></UL>
<P>Only one CResultSet per CStatement can be open at any point in time.
Therefore, if the reading of one CResultSet is interleaved with the reading of
another, each must have been generated by different CStatements. All statement
execute methods implicitly close a statment's current CResultSet if an open one
exists.
<P><B>Note:</B> The setXXX methods for setting IN parameter values must specify
types that are compatible with the defined SQL type of the input parameter. For
instance, if the IN parameter has SQL type Integer then setInt should be used.
<P><B>See Also:</B> </P>
<DL>
<DD><A href="CConnection.html#createStatement">createStatement</A>, <A href="CResultSet.html" >CResultSet</A></DD></DL>
<P>
<HR>
<P></P>
<P>
<TABLE border=1 cellPadding=1 cellSpacing=1 style="HEIGHT: 67px; WIDTH: 578px"
width="75%">
<TR>
<TD><FONT size=+2><B
>Constructor Summary</B></FONT> </TD></TR>
<TR>
<TD><STRONG><A
href="#CStatement">CStatement</A></STRONG>(<A
href="CConnection.html">CConnection</A>*
connection)
<DD>Constructs a <B>CStatement</B> object. Your
derived class must provide a constructor that calls this
one.</DD></TD></TR></TABLE></P>
<P> </P>
<TABLE border=1 cellPadding=1 cellSpacing=1 style="HEIGHT: 63px; WIDTH: 578px"
width="75%">
<TR>
<TD colSpan=2><FONT size=+2><B
>Method Summary</B></FONT> </TD></TR>
<TR>
<TD>
<P align=right><A href="CResultSet.html" >CResultSet</A>*
</P></TD>
<TD><STRONG><A
href="#executeQuery">executeQuery</A></STRONG>()
<DD>A prepared SQL query is executed and its
resultset is returned.</DD></TD></TR>
<TR>
<TD>
<P align=right><A href="CResultSet.html" >CResultSet</A>*<STRONG> </STRONG></P></TD>
<TD><STRONG><A
href="#executeQuery(const char* sql)">executeQuery</A></STRONG>(const char*)
<DD>Execute a SQL statement that returns a single
resultset.</DD></TD></TR>
<TR>
<TD>
<P align=right> int </P></TD>
<TD><STRONG><A
href="#executeUpdate(const char* sql)">executeUpdate</A></STRONG>(const char*)
<DD>Execute a SQL INSERT, UPDATE or DELETE
statement.</DD></TD></TR>
<TR>
<TD>
<P align=right>int </P></TD>
<TD><STRONG><A
href="#executeUpdate">executeUpdate</A></STRONG>()<BR
>
<DD>Execute a SQL INSERT, UPDATE or DELETE
statement.</DD></TD></TR>
<TR>
<TD>
<P align=right>bool </P></TD>
<TD><STRONG><A
href="#isStmSelect">isStmSelect</A></STRONG>()<BR
>
<DD>Return the type of this statement.</DD></TD></TR>
<TR>
<TD>
<P align=right>int </P></TD>
<TD><STRONG><A
href="#prepareStatement">prepareStatement</A></STRONG>(const char*)<BR
>
<DD>A SQL statement with or without IN parameters can
be pre-compiled and stored in a CStatement object.</DD></TD></TR>
<TR>
<TD>
<P align=right>int </P></TD>
<TD><STRONG><A
href="#setDate">setDate</A></STRONG>(const short, const
COCIDate*)<BR>
<DD>Set a parameter to a Oracle Date
value.</DD></TD></TR>
<TR>
<TD>
<P align=right>int </P></TD>
<TD><STRONG><A
href="#setDouble">setDouble</A></STRONG>(const short, const
double*)<BR>
<DD>Set a parameter to a Oracle Double
value.</DD></TD></TR>
<TR>
<TD>
<P align=right>int</P></TD>
<TD><STRONG><A
href="#setFloat">setFloat</A></STRONG>(const short, const
float*)<BR><DD>Set a parameter to a Oracle Float value.</DD> </TD></TR>
<TR>
<TD>
<P align=right>int</P></TD>
<TD><STRONG><A
href="#setInt">setInt</A></STRONG>(const short, const int*)<BR><DD>Set a parameter to a Oracle Integer value.</DD> </TD></TR>
<TR>
<TD>
<P align=right>int </P></TD>
<TD><STRONG><A
href="#setString">setString</A></STRONG>(const short, const
char*)<BR>
<DD>Set a parameter to a Oracle String
value.</DD></TD></TR></TABLE>
<P>
<P> </P>
<P>
<TABLE border=1 cellPadding=1 cellSpacing=1 style="HEIGHT: 23px; WIDTH: 577px"
width="75%">
<TR>
<TD><FONT size=+2><B><FONT size=+2><B>Constructor
Detail</B></FONT></B></FONT></TD></TR></TABLE></P>
<A name=CStatement></A>
<P><STRONG>CStatement::CStatement<BR></STRONG></P>
<P><STRONG>CStatement</STRONG>(<A
href="CConnection.html">CConnection</A>* connection);</P>
<DL>
<DD>Constructs a <STRONG>CStatement</STRONG> object. You can either use
<B>CStatement</B> directly or derive an application-specific class from
<B>CStatement</B>.
<DD><B>Parameters:</B>
<DL><DD>connection - the CConnection handle.</DD></DL></DD></DL>
<P> </P>
<P>
<TABLE border=1 cellPadding=1 cellSpacing=1 style="HEIGHT: 23px; WIDTH: 577px"
width="75%">
<TR>
<TD><FONT size=+2><B>Method Detail</B></FONT></TD></TR></TABLE></P>
<A name=executeQuery></A>
<P><STRONG>CStatement::executeQuery<BR></STRONG></P>
<P><A href="CResultSet.html">CResultSet</A>* <STRONG>executeQuery</STRONG>();</P>
<DL>
<DD>A prepared SQL query is executed and its resultset is returned.
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>pointer to a CResultSet that contains the data produced by the query.</DD></DL></DD></DL>
<HR>
<A name="executeQuery(const char* sql)"></A>
<P><STRONG>CStatement::executeQuery<BR></STRONG></P>
<P><A href="CResultSet.html">CResultSet</A>* <STRONG>executeQuery</STRONG>(const char* sql);</P>
<DL>
<DD>Execute a SQL statement that returns a single resultset.
<DD><B>Parameters:</B>
<DL><DD>sql - typically this is a static SQL SELECT statement.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>pointer to a CResultSet that contains the data produced by the query.</DD></DL></DD></DL>
<HR>
<A name="executeUpdate(const char* sql)"></A>
<P><STRONG>CStatement::executeUpdate<BR></STRONG></P>
<P>int <STRONG>executeUpdate</STRONG>(const char* sql);</P>
<DL>
<DD>Execute a SQL INSERT, UPDATE or DELETE statement.
<DD><B>Parameters:</B>
<DL>
<DD>sql - a SQL INSERT, UPDATE or DELETE statement or a SQL statement that
returns nothing.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A name=executeUpdate></A>
<P><STRONG>CStatement::executeUpdate<BR></STRONG></P>
<P>int <STRONG>executeUpdate</STRONG>();</P>
<DL>
<DD>Execute a SQL INSERT, UPDATE or DELETE statement.
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A name=isStmSelect></A>
<P><STRONG>CStatement::isStmSelect<BR></STRONG></P>
<P>bool <STRONG>isStmSelect</STRONG>();</P>
<DL>
<DD>Return the type of this statement.
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>nonzero if the OCI statement type is SELECT; otherwise
0.</DD></DL></DD></DL>
<HR>
<A name=prepareStatement></A>
<P><STRONG>CStatement::<STRONG>prepareStatement</STRONG><BR></STRONG></P>
<P>int <STRONG>prepareStatement</STRONG>(const char* sql);</P>
<DL>
<DD>A SQL statement with or without IN parameters can be pre-compiled and stored in a CStatement object.
<DD><B>Parameters:</B>
<DL>
<DD> sql - a SQL statement that may contain one or more '?' IN
parameter placeholders.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A name=setDate></A>
<P><STRONG>CStatement::<STRONG>setDate</STRONG><BR></STRONG></P>
<P>int <STRONG>setDate</STRONG>(const short index, const COCIDate* val);</P>
<DL>
<DD>Set a parameter to a Oracle Date value.
<DD><B>Parameters:</B>
<DL>
<DD> index - the first parameter is 1, the second is 2,
...
<DD> val - the
parameter value.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A name=setDouble></A>
<P><STRONG>CStatement::<STRONG>setDouble</STRONG><BR></STRONG></P>
<P>int <STRONG>setDouble</STRONG>(const short index, const
const double* val);</P>
<DL>
<DD>Set a parameter to a Oracle Double value.
<DD><B>Parameters:</B>
<DL>
<DD> index - the first parameter is 1, the second is 2,
...
<DD> val - the
parameter value.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A name=setFloat></A>
<P><STRONG>CStatement::<STRONG>setFloat</STRONG><BR></STRONG></P>
<P>int <STRONG>setFloat</STRONG>(const short index, const
const float* val);</P>
<DL>
<DD>Set a parameter to a Oracle Float value.
<DD><B>Parameters:</B>
<DL>
<DD> index - the first parameter is 1, the second is 2,
...
<DD> val - the
parameter value.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A name=setInt></A>
<P><STRONG>CStatement::<STRONG>setInt</STRONG><BR></STRONG></P>
<P>int <STRONG>setInt</STRONG>(const short index, const
const int* val);</P>
<DL>
<DD> Set a parameter to a Oracle Integer value.
<DD><B>Parameters:</B>
<DL>
<DD> index - the first parameter is 1, the second is 2,
...
<DD> val - the
parameter value.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A name=setString></A>
<P><STRONG>CStatement::<STRONG>setString</STRONG><BR></STRONG></P>
<P>int <STRONG>setString</STRONG>(const short index, const
const char* val);</P>
<DL>
<DD> Set a parameter to a Oracle String value.
<DD><B>Parameters:</B>
<DL>
<DD> index - the first parameter is 1, the second is 2,
...
<DD> val - the
parameter value.</DD></DL>
<DD><STRONG>Returns:</STRONG>
<DL>
<DD>either the error code or 0 for SQL success.</DD></DL></DD></DL>
<HR>
<A href="mailto:yakovlev@zdnetonebox.com">Submit comments/suggestions about
OCL.</A> <BR>Copyright 2001 Sergey Yakovlev. All
Rights Reserved.
<P></P>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -