📄 otl3_const_sql.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>OTL 4.0, Constant SQL statements</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Sergei Kuchin">
<META NAME="GENERATOR" CONTENT="Mozilla/3.03Gold (Win95; I) [Netscape]">
<META NAME="KeyWords" CONTENT="OTL, Oracle, ODBC, DB2, CLI, database API, C++, Template Library">
</HEAD>
<BODY>
<H1 ALIGN=CENTER>OTL 4.0, Constant SQL statements</H1>
<H1><A NAME="otl_constant_sql"></A>Constant SQL statements</H1>
<P>A SQL statement / PL/SQL block / stored procedure call is considered
to be constant if it does not have any bind variables. OTL 4.0 has a static
(in class) function to execute constant statements. </P>
<P><B><FONT SIZE=+1>Examples (Oracle)</FONT></B> </P>
<PRE> otl_cursor::direct_exec
(db, // <A HREF="otl3_connect_class.htm">connect</A> object
"create table test_tab(f1 number, f2 varchar2(30))"
); // create table</PRE>
<PRE> otl_cursor::direct_exec
(db, // <A HREF="otl3_connect_class.htm">connect</A> object
"drop table test_tab", // SQL statement or PL/SQL block
<A HREF="otl3_exception_class.htm#enum">otl_exception::disabled</A> // disable OTL exceptions,
// in other words, ignore any
// database error
); // drop table</PRE>
<P><B><FONT SIZE=+1>Examples (ODBC, DB2-CLI)</FONT></B> </P>
<PRE> otl_cursor::direct_exec
(db, // <A HREF="otl3_connect_class.htm">connect</A> object
"create table test_tab(f1 numeric, f2 varchar(30))"
); // create table</PRE>
<PRE> otl_cursor::direct_exec
(db, // <A HREF="otl3_connect_class.htm">connect</A> object
"drop table test_tab", // SQL statement or stored procedure call
<A HREF="otl3_exception_class.htm#enum">otl_exception::disabled</A> // disable OTL exceptions,
// in other words, ignore any
// database error
); // drop table</PRE>
<P>otl_cursor is one of the OTL 4.0 internal classes. It is not recommended
to use the OTL 4.0 low level classes and functions except for the <I>direct_exec()</I>
because it is a special case and it will not be discontinued in the future
releases of the OTL. </P>
<P>The direct_exec() function may return the following values of the <I>long
int </I>datatype: </P>
<UL>
<LI><B>-1</B>, if otl_exceptions are disabled (the second parameter is
set to otl_exception::disabled) and the underlying API returns an error.</LI>
<LI><B>>=0</B>, if the SQL command to be executed is finished succesfully.
Actually, the function returns the <I>ROWS PROCESSED COUNT </I>(RPC)in
case of INSERT, UPDATE or DELETE statements.</LI>
</UL>
<P>Here is an example of the direct_exec(), returning a row processed count:
<BR>
</P>
<PRE> long rpc=otl_cursor::direct_exec
(db, // <A HREF="otl3_connect_class.htm">connect</A> object
"delete from test_tab where f1>=95"
);
cout<<"Rows deleted: "<<rpc<<endl;</PRE>
<P> </P>
<P> <BR>
<BR>
<BR>
</P>
<CENTER><P>
<HR WIDTH="100%"></P></CENTER>
<CENTER><P><A HREF="otl3_value.htm">Prev</A> <A HREF="otl3_examples.htm">Next</A><A HREF="otl3.htm">Contents</A><A HREF="home.htm">Go
Home</A> </P></CENTER>
<P>Copyright © 1996, 2008, Sergei Kuchin, email: <A HREF="mailto:skuchin@aceweb.com">skuchin@aceweb.com</A>,
<A HREF="mailto:skuchin@gmail.com">skuchin@gmail.com</A>.<SCRIPT Language="JavaScript"><!-- hide from oldgmailsers
var modDate = new Date(document.lastModified)
document.write("<i> Last Updated:</i> " + (modDate.getMonth()+1) + "/" +
modDate.getDate() + "/" + "0"+(modDate.getYear())%100+".");
//-->
</SCRIPT></P>
<P><I>Permission to use, copy, modify and redistribute this document for
any purpose is hereby granted without fee, provided that the above copyright
notice appear in all copies.</I> </P>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5456201-1");
pageTracker._trackPageview();
</script>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -