📄 command_usage.html
字号:
<html><head><meta name="KEYWORDS" content=" library, C++, Oracle, SQLServer, DB2, Sybase, Informix, InterBase, SQLBase, ODBC,
SQL, server, client, database, programming, development, software,
Win32, Windows, Linux, Unix, Solaris,
Microsoft, Borland, Centura, Gupta, IBM"><meta name="DESCRIPTION" content=
"SQLAPI++ is C++ library for accessing SQL databases (Oracle, SQLServer, Sybase, DB2, InterBase, SQLBase, Informix, ODBC).
It uses native APIs, provides low-level access to database-specific features."><title>SQLAPI++ Library - Online Documentation - SACommand object</title></head><body bgcolor="#ffffff" BACKGROUND="../images/bg.gif" text="#000000"><!--GlbHdr--> <table WIDTH="600" height="40" frame="hsides" BORDER="2" BORDERCOLOR="#004fcd" align="right" cellpadding="0" cellspacing="2" id="TABLE1">
<tr><!--class="GlbDefault"-->
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../index.html" style="TEXT-DECORATION: none">
<font color="white" size="3" face="sans-serif">
<b>Home</b></font></A></td></TD>
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../HowTo/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>How To</b></font></A></td><!--class="GlbActive"-->
<td width="70" bgcolor="#00bb00" bordercolor="black" align="middle"><A href="../OnLineDoc/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>Online Documentation</b></font></A></td><!--class="GlbDefault"-->
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../Support/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>Support</b></font></A></td>
<td width=70 bgcolor=#000094 bordercolor=black align=middle>
<A href="../Download/index.html" style="TEXT-DECORATION: none" >
<font color=white size=3
face=sans-serif>
<b>Download</b></font></A></td>
<td width="70" bgcolor="#000094" bordercolor="black" align="middle"><A href="../Order/index.html" style="TEXT-DECORATION: none"> <font color="white" size="3" face="sans-serif">
<b>Order</b></font></A></td> </tr>
</table>
<p> </p>
<table width="100%">
<tr>
<td valign="top" width="165"><!--LeftMenu-->
<table frame="void" CELLSPACING="5" width="165">
<tr><td><p> </p></td>
</tr>
<tr>
<td><img align="middle" src="../images/red.gif" WIDTH="12" HEIGHT="12">
<A href="Command.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SACommand</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Connection.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAConnection</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Exception.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAException</font></A> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Field.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAField</A> </FONT> </td>
</tr>
<tr>
<td><img align="middle" src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="Param.html" style="TEXT-DECORATION: none">
<font color="white" size="2" face="sans-serif">
SAParam</A> </FONT> </td>
</tr>
<tr><td><hr></td></tr>
<tr>
<td><img align=middle src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="String.html" style ="TEXT-DECORATION: none" >
<font color=white size=2 face=sans-serif>
SAString</A> </FONT> </td>
</tr>
<tr>
<td><img align=middle src="../images/green.gif" WIDTH="12" HEIGHT="12">
<A href="DateTime.html" style ="TEXT-DECORATION: none" >
<font color=white size=2 face=sans-serif>
SADateTime</A> </FONT> </td>
</tr>
</table>
</td><!--empty column-->
<td width="20">
<p> </p>
</td><!--Content-->
<td valign="top" align="left">
<table width="100%" cellspacing="2" cellpadding="2">
<tr>
<td align="left">
<A href="Command.html" style="TEXT-DECORATION: none"><h3>Class Members</h3></A>
</td>
<td align="left">
<A href="Command_Examples.html" style="TEXT-DECORATION: none"><h3>Examples</h3></A>
</td>
</tr>
<tr>
<td colspan="2"><h1>SACommand object</h1></td>
</tr>
</table>
<p>A <b>SACommand</b> object defines a specific command that you intend to execute against a data source.<p>
<p>A <b>SACommand</b>
object
may be used to query a database and return records, insert or update data, to
manipulate the structure of a database, or to run a stored procedure.</p>
<p>With the methods of a <b>SACommand</b> object you can do the following:
<ul type="disc">
<li>Associate an opened connection with a <b>SACommand</b>
object by using its
<A href="Command_setConnection.html">setConnection</A> method.<br><br>
<li>Define the executable text of the command (for example, a SELECT statement or a stored procedure name) and the command type
with the <A href="Command_setCommandText.html">setCommandText</A> method.<br><br>
<li>Bind query input variables assigning <b>SAParam</b>
object(s) returning by
<A href="Command_Param.html">Param</A>
and <A href="Command_ParamByIndex.html">ParamByIndex</A>
methods,
or bind input variables using stream <A href="Command_operator_bind.html">operator <<</A>.<br><br>
<li>Execute a command using <A href="Command_Execute.html">Execute</A> method.<br><br>
<li>Check whether a result set exists using <A href="Command_isResultSet.html">isResultSet</A>
method, and fetch row by row from it with the <A href="Command_FetchNext.html">FetchNext</A> method.
Get <b>SAField</b>
objects with <A href="Command_Field.html">Field</A> method and access their
descriptions and values.<br><br>
<li>Receive output
variables and access their values using
<A href="Command_Param.html">Param</A>
and <A href="Command_ParamByIndex.html">ParamByIndex</A>
methods.</li>
</ul>
<p>You can construct command based on the given connection, or with no associated <A href="Connection.html">SAConnection</A>
object using appropriate <A href="Command_cnstr.html">SACommand</A>
constructor.
If you create new command with no connection, you need to use <A href="Command_setConnection.html">setConnection</A>
method before executing any other <b>SACommand</b> methods.
</p>
<p>To set command text use <A href="Command_setCommandText.html">setCommandText</A>
method. If the command has parameters, a set of
<strong>SAParam</strong>
objects creates implicitly.
You can get the number of parameters with <A href="Command_ParamCount.html">ParamCount</A>
method and look
them through (and assign) with <A href="Command_Param.html">Param</A>
and <A href="Command_ParamByIndex.html">ParamByIndex</A>
methods. Values for
the input parameters can also be supplied by <A href="Command_operator_bind.html">operator <<</A>.
</p>
<p>To prepare a command use <A href="Command_Prepare.html">Prepare</A>
method. If you will not
prepare a command it will be prepared implicitly before execution.
If needed a command will be implicitly opened. If, for some reason,
you want to open a command explicitly use <A href="Command_Open.html">Open</A>
method. To execute a command use <A href="Command_Execute.html">Execute</A>
method. A command will be
implicitly closed in destructor. If, for some reason, you want to
close a command explicitly use <A href="Command_Close.html">Close</A>
method. To test whether a command
is opened use <A href="Command_isOpened.html">isOpened</A> method.
</p>
<p>A command (an SQL statement or procedure) can have a result set after executing.
To check whether a result set exists use <A href="Command_isResultSet.html">isResultSet</A> method.
If result set exists, a set of <b>SAField</b> objects created implicitly.
<b>SAField</b>
object contains full information about a field (name, type, size, etc.) and
a field's value after fetching a row (<A href="Command_FetchNext.html">FetchNext</A>
method).
You can get the number of fields with <A href="Command_FieldCount.html">FieldCount</A>
method
and look them through with <A href="Command_Field.html">Field</A>
method or <A href="Command_operator_get.html">operator []</A>
.
</p>
<p>If command has output parameters, you can
get
them after a command execution using
<A href="Command_Param.html">Param</A>
and <A href="Command_ParamByIndex.html">ParamByIndex</A> methods.
</p>
<h3>Problems and Questions</h3>
<p>
If
you don't find the answer to you questions or
have some problems on using the Library, please, send e-mail to <A href="mailto:howto@sqlapi.com">howto@sqlapi.com</A>.
</p>
</td>
<tr></tr>
</table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -