dbstmt.htm

来自「The goal of this library is to make ODBC」· HTM 代码 · 共 210 行

HTM
210 行
字号
<html>


<head>
<style>
CODE {COLOR: #990000;}
.code{COLOR: #990000}
.codeComment{COLOR: #008000}
.codeHighlight{BACKGROUND-COLOR: #FFFF00}
.codeFileName{FONT-WEIGHT: bold;}
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Gradman">
<meta name="KeyWords"
content="DTL, Oracle, ODBC, database API, C++, Template Library">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<!--
  -- Copyright 2000
  -- Michael Gradman & Corwin Joy
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Corwin Joy & Michael Gradman make no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  --
  -- Copyright (c) 1996-1999
  -- Silicon Graphics Computer Systems, Inc.
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Silicon Graphics makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -- Copyright (c) 1994
  -- Hewlett-Packard Company
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Hewlett-Packard Company makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -->
<!-- Generated by htmldoc -->
<title>DBStmt</title>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#0000EE"
vlink="#551A8B" alink="#FF0000">

<p><font size="6" face="Bookman Old Style"><em><strong><u>dtl</u></strong></em></font></p>

<p><img src="stat.gif" width="6" height="6"> <!--end header--> <br>
</p>
<h1>DBStmt</h1>



















<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td><img src="utilities.gif" width="194" height="38"></td>
        <td align="right"><img src="type.gif" width="194"
        height="39"></td>
    </tr>
    <tr>
        <td valign="top"><b>Category</b>: utilities</td>
        <td align="right" valign="top"><b>Component type</b>:
        type</td>
    </tr>
</table>
<h3>Description</h3>

<p>The <font size="2" face="Courier New">DBStmt </font>object manages a single ODBC statement, such as
INSERT, SELECT, UPDATE or native SQL strings that need to be
passed through to the database.</p>

<h3>Definition</h3>

<p>Defined in the <font size="2" face="Courier New">DBStmt.h </font>header
file.</p>

<h3>Refinement of</h3>

<p>None.</p>

<h3>Associated types</h3>

<p>None.</p>

<h3>Example: Executing a SQL Statement Directly via DBStmt</h3>

<pre><code>int main(int argc, char **argv)
{
  DBConnection::GetDefaultConnection().Connect(&quot;UID=example;PWD=example;DSN=example;&quot;);
  DBStmt(&quot;DELETE FROM DB_EXAMPLE&quot;).Execute();
  DBStmt(&quot;INSERT INTO DB_EXAMPLE SELECT * FROM DB_EXAMPLE_BACKUP&quot;).Execute();
}
</code></pre>

<h3><font size="4">Public Base Classes</font></h3>

<p><a href="ValidatedObject.htm"><font size="2"
face="Courier New">ValidatedObject</font></a></p>

<h3>Notation</h3>

<table border="0">
    <tr>
        <td valign="top"><tt>X</tt> </td>
        <td valign="top">A type that is a model of DBStmt </td>
    </tr>
    <tr>
        <td valign="top"><tt>a</tt> </td>
        <td valign="top">Object of type <tt>X</tt> </td>
    </tr>
</table>

<h3>Expression semantics</h3>

<table border="1">
    <tr>
        <th>Name </th>
        <th>Expression </th>
        <th>Precondition </th>
        <th>Semantics </th>
        <th>Postcondition </th>
    </tr>
    <tr>
        <td valign="top">Constructor </td>
        <td valign="top"><pre>X a(string query, 
DBConnection &amp;connection = DBConnection::GetDefaultConnection())</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Creates an ODBC statement using the
        string in query and the <a href="DBConnection.htm">DBConnection</a>
        object specified by connection. If no connection object
        is passed in to the constructor, the default connection
        object is used. The SQL statement is SQLPrepared against
        the database at construction time so that Execute() can
        run quickly if it needs to be called multiple times.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Execute a statement</td>
        <td valign="top"><pre>Execute()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Execute the SQL string held by the
        statement</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Swap with another connection</td>
        <td valign="top"><pre>void swap(X &amp;other)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Swap <font size="2" face="Courier New">*this</font>
        with <font size="2" face="Courier New">other</font>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
</table>

<h3>Notes</h3>

<h3>See also</h3>

<p><a href="DBConnection.htm"><font size="2" face="Courier New">DBConnection</font></a><font
size="2" face="Courier New">, </font><a
href="DBView.htm"><font size="2" face="Courier New">DBView</font></a><font
size="2" face="Courier New">, </font><a
href="IndexedDBView.htm"><font size="2"
face="Courier New">IndexedDBView</font></a><font size="2"
face="Courier New">, </font><a href="ValidatedObject.htm"><font
size="2" face="Courier New">ValidatedObject</font></a><a
href="IndexedDBView.htm"><font size="2"><!--start footer--></font></a></p>


<hr>

<p><a href="index.htm"><img src="dtl_home.gif" alt="[DTL Home]"
width="54" height="54"></a> <br>
</p>

<p>Copyright 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?