<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;C04NR3s9cSp7ImA9WxJUE04.&quot;"><id>tag:blogger.com,1999:blog-17554078</id><updated>2009-07-11T13:06:36.569-04:00</updated><title>Mark Williams :: Blog</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://oradim.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><link rel="self" href="http://feeds.feedburner.com/oradim" type="application/atom+xml" /><entry gd:etag="W/&quot;C04NR3szeyp7ImA9WxJUE04.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-5538698361884360474</id><published>2009-07-11T11:18:00.016-04:00</published><updated>2009-07-11T13:06:36.583-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-11T13:06:36.583-04:00</app:edited><title>SQL*Plus, EZCONNECT, Password Prompt, and ORA-12504</title><content type="html">I use SQL*Plus a great deal and I find the "&lt;a href="http://download.oracle.com/docs/cd/B28359_01/network.111/b28316/naming.htm#BABIHAAA" target="_blank"&gt;Easy Connect Naming Method&lt;/a&gt;" a convenient option.&lt;br /&gt;&lt;br /&gt;Before you get any further in this post, let me be perfectly clear that this post &lt;b&gt;only&lt;/b&gt; addresses ORA-12504 in the context of using the "Easy Connect Naming Method" with SQL*Plus and password prompting. It does &lt;b&gt;not&lt;/b&gt; address ORA-12504 outside of this context. The documentation (see the link above) has several examples of using and configuring this method, so I won't go into them all here. This method is also known as "EZCONNECT" presumably because "Z" in the American dialect is pronounced like "zee" rather than "zed".&lt;br /&gt;&lt;br /&gt;You are likely already familiar with the password prompting behavior of SQL*Plus. For example, when using a tnsnames.ora file alias to connect to a database, if the password is not specified, SQL*Plus will prompt you for it (i.e. "Enter password:"):&lt;br /&gt;&lt;p&gt;&lt;nobr&gt;&lt;font face="Courier New"&gt;&lt;br /&gt;[oracle@liverpool&amp;nbsp;~]$&amp;nbsp;sqlplus&amp;nbsp;hr@orademo&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL*Plus:&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&amp;nbsp;on&amp;nbsp;Sat&amp;nbsp;Jul&amp;nbsp;11&amp;nbsp;11:42:08&amp;nbsp;2009&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Copyright&amp;nbsp;(c)&amp;nbsp;1982,&amp;nbsp;2008,&amp;nbsp;Oracle.&amp;nbsp;&amp;nbsp;All&amp;nbsp;rights&amp;nbsp;reserved.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Enter&amp;nbsp;password:&amp;nbsp;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Connected&amp;nbsp;to:&lt;br /&gt;Oracle&amp;nbsp;Database&amp;nbsp;11g&amp;nbsp;Enterprise&amp;nbsp;Edition&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&lt;br /&gt;With&amp;nbsp;the&amp;nbsp;Partitioning,&amp;nbsp;OLAP,&amp;nbsp;Data&amp;nbsp;Mining&amp;nbsp;and&amp;nbsp;Real&amp;nbsp;Application&amp;nbsp;Testing&amp;nbsp;options&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL&gt;&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/nobr&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;Nice and easy.&lt;br /&gt;&lt;br /&gt;So, let's try the equivalent using EZCONNECT:&lt;br /&gt;&lt;p&gt;&lt;nobr&gt;&lt;font face="Courier New"&gt;&lt;br /&gt;[oracle@liverpool&amp;nbsp;~]$&amp;nbsp;sqlplus&amp;nbsp;hr@liverpool:1521/DEMO&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL*Plus:&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&amp;nbsp;on&amp;nbsp;Sat&amp;nbsp;Jul&amp;nbsp;11&amp;nbsp;11:43:20&amp;nbsp;2009&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Copyright&amp;nbsp;(c)&amp;nbsp;1982,&amp;nbsp;2008,&amp;nbsp;Oracle.&amp;nbsp;&amp;nbsp;All&amp;nbsp;rights&amp;nbsp;reserved.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;ERROR:&lt;br /&gt;ORA-12504:&amp;nbsp;TNS:listener&amp;nbsp;was&amp;nbsp;not&amp;nbsp;given&amp;nbsp;the&amp;nbsp;SERVICE_NAME&amp;nbsp;in&amp;nbsp;CONNECT_DATA&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Enter&amp;nbsp;user-name:&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/nobr&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;Hmm... well, that's interesting. Rather than getting prompted for the password we get an error (ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA) and then we get presented with the "Enter user-name:" prompt again. Funny that the error is saying the SERVICE_NAME was not specified, but it sure is there - DEMO in this case. This is giving us a clue though...&lt;br /&gt;&lt;br /&gt;OK, so let's go ahead and specify the password:&lt;br /&gt;&lt;p&gt;&lt;nobr&gt;&lt;font face="Courier New"&gt;&lt;br /&gt;[oracle@liverpool&amp;nbsp;~]$&amp;nbsp;sqlplus&amp;nbsp;hr/hr@liverpool:1521/DEMO&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL*Plus:&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&amp;nbsp;on&amp;nbsp;Sat&amp;nbsp;Jul&amp;nbsp;11&amp;nbsp;11:44:02&amp;nbsp;2009&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Copyright&amp;nbsp;(c)&amp;nbsp;1982,&amp;nbsp;2008,&amp;nbsp;Oracle.&amp;nbsp;&amp;nbsp;All&amp;nbsp;rights&amp;nbsp;reserved.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Connected&amp;nbsp;to:&lt;br /&gt;Oracle&amp;nbsp;Database&amp;nbsp;11g&amp;nbsp;Enterprise&amp;nbsp;Edition&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&lt;br /&gt;With&amp;nbsp;the&amp;nbsp;Partitioning,&amp;nbsp;OLAP,&amp;nbsp;Data&amp;nbsp;Mining&amp;nbsp;and&amp;nbsp;Real&amp;nbsp;Application&amp;nbsp;Testing&amp;nbsp;options&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL&gt;&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/nobr&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;Much better, it works, but what if you (reasonably) don't want to specify the password on the command-line?&lt;br /&gt;&lt;br /&gt;Taking a look at the documentation (really - that stuff does come in handy!) for the &lt;a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b31189/ch12015.htm#i2697450" target="blank"&gt;CONNECT&lt;/a&gt; SQL*Plus command we can see this:&lt;br /&gt;&lt;br /&gt;username[/password] [@connect_identifier]&lt;br /&gt;&lt;br /&gt;Pay particular attention that the "/" precedes the password. In the case of using EZCONNECT we have:&lt;br /&gt;&lt;br /&gt;sqlplus hr@liverpool:1521/DEMO&lt;br /&gt;&lt;br /&gt;So, in this case the "/" precedes the SERVICE_NAME and not the password. How should we tell SQL*Plus that the "/" is not preceding the password? We quote the connection string!&lt;br /&gt;&lt;p&gt;&lt;nobr&gt;&lt;font face="Courier New"&gt;&lt;br /&gt;[oracle@liverpool&amp;nbsp;~]$&amp;nbsp;sqlplus&amp;nbsp;hr@\"liverpool:1521/DEMO\"&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL*Plus:&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&amp;nbsp;on&amp;nbsp;Sat&amp;nbsp;Jul&amp;nbsp;11&amp;nbsp;11:45:43&amp;nbsp;2009&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Copyright&amp;nbsp;(c)&amp;nbsp;1982,&amp;nbsp;2008,&amp;nbsp;Oracle.&amp;nbsp;&amp;nbsp;All&amp;nbsp;rights&amp;nbsp;reserved.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Enter&amp;nbsp;password:&amp;nbsp;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Connected&amp;nbsp;to:&lt;br /&gt;Oracle&amp;nbsp;Database&amp;nbsp;11g&amp;nbsp;Enterprise&amp;nbsp;Edition&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&lt;br /&gt;With&amp;nbsp;the&amp;nbsp;Partitioning,&amp;nbsp;OLAP,&amp;nbsp;Data&amp;nbsp;Mining&amp;nbsp;and&amp;nbsp;Real&amp;nbsp;Application&amp;nbsp;Testing&amp;nbsp;options&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL&gt;&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/nobr&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;Now that's more like it! Notice that I used "\" (backslash) to escape the double-quote characters on the command-line (I'm using the bash shell for this).&lt;br /&gt;&lt;br /&gt;If you are already in SQL*Plus you do not need to use the backslash to escape the double-quote characters:&lt;br /&gt;&lt;p&gt;&lt;nobr&gt;&lt;font face="Courier New"&gt;&lt;br /&gt;[oracle@liverpool&amp;nbsp;~]$&amp;nbsp;sqlplus&amp;nbsp;/nolog&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL*Plus:&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&amp;nbsp;on&amp;nbsp;Sat&amp;nbsp;Jul&amp;nbsp;11&amp;nbsp;11:46:31&amp;nbsp;2009&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Copyright&amp;nbsp;(c)&amp;nbsp;1982,&amp;nbsp;2008,&amp;nbsp;Oracle.&amp;nbsp;&amp;nbsp;All&amp;nbsp;rights&amp;nbsp;reserved.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL&gt;&amp;nbsp;connect&amp;nbsp;hr@"liverpool:1521/DEMO"&lt;br /&gt;Enter&amp;nbsp;password:&amp;nbsp;&lt;br /&gt;Connected.&lt;br /&gt;SQL&gt;&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/nobr&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;This same technique can also be used for privileged connections:&lt;br /&gt;&lt;p&gt;&lt;nobr&gt;&lt;font face="Courier New"&gt;&lt;br /&gt;[oracle@liverpool&amp;nbsp;~]$&amp;nbsp;sqlplus&amp;nbsp;sys@\"liverpool:1521/DEMO\"&amp;nbsp;as&amp;nbsp;sysdba&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL*Plus:&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&amp;nbsp;on&amp;nbsp;Sat&amp;nbsp;Jul&amp;nbsp;11&amp;nbsp;11:47:23&amp;nbsp;2009&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Copyright&amp;nbsp;(c)&amp;nbsp;1982,&amp;nbsp;2008,&amp;nbsp;Oracle.&amp;nbsp;&amp;nbsp;All&amp;nbsp;rights&amp;nbsp;reserved.&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Enter&amp;nbsp;password:&amp;nbsp;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;Connected&amp;nbsp;to:&lt;br /&gt;Oracle&amp;nbsp;Database&amp;nbsp;11g&amp;nbsp;Enterprise&amp;nbsp;Edition&amp;nbsp;Release&amp;nbsp;11.1.0.7.0&amp;nbsp;-&amp;nbsp;Production&lt;br /&gt;With&amp;nbsp;the&amp;nbsp;Partitioning,&amp;nbsp;OLAP,&amp;nbsp;Data&amp;nbsp;Mining&amp;nbsp;and&amp;nbsp;Real&amp;nbsp;Application&amp;nbsp;Testing&amp;nbsp;options&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;SQL&gt;&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/nobr&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;If you use SQL*Plus as much as I do, perhaps this will be a handy tip.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-5538698361884360474?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/5538698361884360474/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/07/sqlplus-ezconnect-password-prompt-and.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/5538698361884360474?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/5538698361884360474?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/TC4nMija43g/sqlplus-ezconnect-password-prompt-and.html" title="SQL*Plus, EZCONNECT, Password Prompt, and ORA-12504" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/07/sqlplus-ezconnect-password-prompt-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkIDQXszeCp7ImA9WxJVGU4.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-4448777685595550400</id><published>2009-07-06T23:46:00.001-04:00</published><updated>2009-07-06T23:49:30.580-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-06T23:49:30.580-04:00</app:edited><title>Getting Started with OCCI (Windows Version)</title><content type="html">&lt;p&gt;The Oracle C++ Call Interface, also known as OCCI, is an application programming interface (API) built upon the Oracle Call Interface (OCI - another lower level API from Oracle). One of the goals of OCCI is to offer C++ programmers easy access to Oracle Database in a fashion similar to what Java Database Connectivity (JDBC) affords Java developers. If you would like to learn more about what OCCI is (and isn't), pay a visit to the OCCI documentation on Oracle Technology Network (OTN) here:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28390/toc.htm" href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28390/toc.htm"&gt;http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28390/toc.htm&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;My goal with this &amp;quot;Getting Started&amp;quot; post is to give you one method of setting up an environment in which you can use OCCI to develop C++ applications under Windows that access Oracle Database. I am not in any way covering all possible scenarios or delving deep into OCCI itself. Please note that the database itself can be on any supported host.&lt;/p&gt;  &lt;h3&gt;The Environment&lt;/h3&gt;  &lt;p&gt;Your environment is likely to differ from mine; however, it is important to be familiar with the various components in the environment used here so that you can make adaptations as necessary for your specific environment.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Oracle Database Server/Host: oel01 (Oracle Enterprise Linux 32-bit server) &lt;/li&gt;    &lt;li&gt;Oracle Database: SID value of OEL11GR1, Service Name value of OEL11GR1.SAND, version 11.1.0.7 &lt;/li&gt;    &lt;li&gt;Development Machine: Hostname of CHEPSTOW, Windows XP Professional 32-bit &lt;/li&gt;    &lt;li&gt;Development IDE: Microsoft Visual C++ 2008 Express Edition (Windows SDK also installed) &lt;/li&gt;    &lt;li&gt;Oracle Client: Oracle Instant Client with OCCI &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Important Information&lt;/h3&gt;  &lt;p&gt;One of the most crucial attributes of working with OCCI is that you &lt;em&gt;must&lt;/em&gt; ensure that &lt;em&gt;all&lt;/em&gt; of the components of the development environment &lt;em&gt;and&lt;/em&gt; the runtime environment are supported combinations and correct versions. I can not emphasize this enough. If you deviate from this, you will almost certainly find trouble! In order to find the correct combinations of products and versions, see the following links on OTN:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.oracle.com/technology/tech/oci/occi/index.html" target="_blank"&gt;Oracle C++ Call Interface&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.oracle.com/technology/tech/oci/occi/occidownloads.html" target="_blank"&gt;OCCI Downloads page&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.oracle.com/technology/tech/oci/instantclient/index.html" target="_blank"&gt;Oracle Database Instant Client&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.oracle.com/technology/software/tech/oci/instantclient/index.html" target="_blank"&gt;Instant Client Downloads&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html" target="_blank"&gt;Instant Client Downloads for Windows 32-bit&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Download the Correct Packages&lt;/h3&gt;  &lt;p&gt;At the time of this writing, the following are the component versions supported for the environment listed above:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;OCCI 11.1.0.6 (Visual C++9 (VS 2008)[Windows 32-bit]) &lt;/li&gt;    &lt;li&gt;Instant Client Version 11.1.0.6 &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;From the download links above, you should download the following components to your development machine. I downloaded them to the C:\Temp directory.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;OCCI 11.1.0.6 (Visual C++9 (VS 2008)[Windows 32-bit]) - occivc9win32_111060.zip &lt;/li&gt;    &lt;li&gt;Instant Client Package - Basic: instantclient-basic-win32-11.1.0.6.0.zip &lt;/li&gt;    &lt;li&gt;Instant Client Package - SDK: instantclient-sdk-win32-11.1.0.6.0.zip &lt;/li&gt;    &lt;li&gt;Instant Client Package - SQL*Plus: instantclient-sqlplus-win32-11.1.0.6.0.zip&amp;#160; (optional, but I always install it) &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Install the Instant Client Packages&lt;/h3&gt;  &lt;p&gt;Installing the Instant Client packages is simply a matter of unzipping them – not much to wrong here! I unzipped them all to the C:\ directory on Chepstow. This resulted in a new top-level directory - C:\instantclient_11_1 with &amp;quot;sdk&amp;quot;, &amp;quot;vc8&amp;quot;, and &amp;quot;vc7&amp;quot; directories underneath. The &amp;quot;vc8&amp;quot; and &amp;quot;vc7&amp;quot; directories should be ignored in the context of the environment created here.&lt;/p&gt;  &lt;h3&gt;Install the OCCI Package&lt;/h3&gt;  &lt;p&gt;Much like the Instant Client packages, the OCCI package should be unzipped; however, rather than unzipping it to the C:\ directory, I unzipped it to the C:\Temp directory. Once unzipped, review the occivc9_111060_readme.txt file for information; however, I deviate from the directories listed in the file.&lt;/p&gt;  &lt;p&gt;I create a &amp;quot;vc9&amp;quot; directory under the &amp;quot;sdk&amp;quot; directory as follows:&lt;/p&gt;  &lt;p&gt;C:\instantclient_11_1\sdk\lib\msvc\vc9&lt;/p&gt;  &lt;p&gt;I create a &amp;quot;vc9&amp;quot; directory under the &amp;quot;instantclient_11_1&amp;quot; directory as follows:&lt;/p&gt;  &lt;p&gt;C:\instantclient_11_1\vc9&lt;/p&gt;  &lt;p&gt;I delete the oraocci11.dll and oraocci11.sym files from the C:\instantclient_11_1 directory. These files are not built/linked with the runtime libraries used by Visual Studio 2008 and, as mentioned above, it is critical that component versions match!&lt;/p&gt;  &lt;p&gt;From the extracted OCCI files in the C:\Temp directory, move the following two files to the C:\instantclient_11_1\sdk\lib\msvc\vc9 directory previously created:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;oraocci11.lib &lt;/li&gt;    &lt;li&gt;oraocci11d.lib &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;From the extracted OCCI files in the C:\Temp directory, move the following four files to the C:\instantclient_11_1\vc9 directory previously created:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;oraocci11.dll &lt;/li&gt;    &lt;li&gt;oraocci11.dll.manifest &lt;/li&gt;    &lt;li&gt;oraocci11d.dll &lt;/li&gt;    &lt;li&gt;oraocci11d.dll.manifest &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Finally, delete the oraocci11.lib file from the C:\instantclient_11_1\sdk\lib\msvc directory. Again, this file is not compatible with the environment created here.&lt;/p&gt;  &lt;p&gt;After performing these steps, the .lib files should only be in directories under C:\instantclient_11_1\sdk\lib\msvc and the .dll and .manifest files should only be in directories under the C:\instantclient_11_1 directory. While this may seem like extra unneeded work, it results in complete separation of the various versions of the OCCI components making it easier (and explicit) which version is to be used.&lt;/p&gt;  &lt;p&gt;To specify which version of the OCCI libraries are used, add the directory to the system path. You also add the the Instant Client directory to the path. Both of these directories should be added to the beginning of the system path:&lt;/p&gt;  &lt;p&gt;C:\instantclient_11_1\vc9;C:\instantclient_11_1;{rest of path follows…}&lt;/p&gt;  &lt;h3&gt;Configure Visual Studio&lt;/h3&gt;  &lt;p&gt;The Windows environment has been configured to use the new OCCI and Instant Client packages but before you can begin developing in Visual Studio, you need to set a few options. Without these options Visual Studio will be unable to find the correct files and build your applications. There are two options that need to be specified:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Include files – allows Visual Studio to find the header files for OCCI &lt;/li&gt;    &lt;li&gt;Library files – allows Visual Studio to find the library files for OCCI &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Using Visual C++ 2008 Express Edition, the menu paths to specify these options are as follows:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Tools –&amp;gt; Options… Expand &amp;quot;Projects and Solutions&amp;quot; node, select &amp;quot;VC++ Directories&amp;quot;, under &amp;quot;Show directories for:&amp;quot; select &amp;quot;Include files&amp;quot;, double-click under the last entry to open a new box to enter a path, enter &amp;quot;C:\instantclient_11_1\sdk\include&amp;quot; and press enter &lt;/li&gt;    &lt;li&gt;Under &amp;quot;Show directories for:&amp;quot; select &amp;quot;Library files&amp;quot;, double-click under the last entry to open a new box to enter a path, enter &amp;quot;C:\instantclient_11_1\sdk\lib\msvc\vc9&amp;quot; and press enter &lt;/li&gt;    &lt;li&gt;Click OK to save the settings &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Create a Simple Test Project&lt;/h3&gt;  &lt;p&gt;All the setup work is now complete and the environment is configured! If needed, you can use the following (very!) basic application as a simple test to verify things are working as expected. Again, this is a simple example only to verify things are setup correctly. It is not intended to be a complete template for &amp;quot;proper&amp;quot; code development, etc.&lt;/p&gt;  &lt;p&gt;Create the Visual C++ 2008 Express Edition project by selecting File –&amp;gt; New –&amp;gt; Project… from the main menu, select &amp;quot;Win32&amp;quot; as the project type, select &amp;quot;Win32 Console Application&amp;quot;, give the project a name (I used OCCITest), select a location (I used C:\Projects), I unchecked &amp;quot;Create directory for solution&amp;quot;, and then click OK.&lt;/p&gt;  &lt;p&gt;Click Next in the Application Wizard, uncheck Precompiled header, click Empty project, and click Finish.&lt;/p&gt;  &lt;p&gt;In Solution Explorer, right-click Header Files, select Add, select New Item…&lt;/p&gt;  &lt;p&gt;In Add New Item, select Header File (.h), enter Employees.h (or any name you prefer) in Name, and click Add.&lt;/p&gt;  &lt;p&gt;Here's the content of the file on my system:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;/*      &lt;br /&gt; * A simple OCCI test application       &lt;br /&gt; * This file contains the Employees class declaration       &lt;br /&gt; */ &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;#include &amp;lt;occi.h&amp;gt;      &lt;br /&gt;#include &amp;lt;iostream&amp;gt;       &lt;br /&gt;#include &amp;lt;iomanip&amp;gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using namespace oracle::occi;      &lt;br /&gt;using namespace std; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;class Employees {      &lt;br /&gt;public:       &lt;br /&gt;&amp;#160; Employees();       &lt;br /&gt;&amp;#160; virtual ~Employees(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; void List(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;private:      &lt;br /&gt;&amp;#160; Environment *env;       &lt;br /&gt;&amp;#160; Connection&amp;#160; *con; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; string user;      &lt;br /&gt;&amp;#160; string passwd;       &lt;br /&gt;&amp;#160; string db;       &lt;br /&gt;};&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;In Solution Explorer, right-click Source Files, select Add, select New Item…&lt;/p&gt;  &lt;p&gt;In Add New Item, select C++ File (.cpp), enter Employees.cpp (or any name you prefer) in Name, and click Add.&lt;/p&gt;  &lt;p&gt;Here's the content of the file on my system:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;/*      &lt;br /&gt; * A simple OCCI test application       &lt;br /&gt; * This file contains the Employees class implementation       &lt;br /&gt; */ &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;#include &amp;quot;Employees.h&amp;quot; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using namespace std;      &lt;br /&gt;using namespace oracle::occi; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;int main (void)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160;&amp;#160; * create an instance of the Employees class,       &lt;br /&gt;&amp;#160;&amp;#160; * invoke the List member, delete the instance,       &lt;br /&gt;&amp;#160;&amp;#160; * and prompt to continue...       &lt;br /&gt;&amp;#160;&amp;#160; */ &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; Employees *pEmployees = new Employees(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; pEmployees-&amp;gt;List(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; delete pEmployees; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; cout &amp;lt;&amp;lt; &amp;quot;ENTER to continue...&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; cin.get(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; return 0;      &lt;br /&gt;} &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Employees::Employees()      &lt;br /&gt;{       &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160;&amp;#160; * connect to the test database as the HR       &lt;br /&gt;&amp;#160;&amp;#160; * sample user and use the EZCONNECT method       &lt;br /&gt;&amp;#160;&amp;#160; * of specifying the connect string. Be sure       &lt;br /&gt;&amp;#160;&amp;#160; * to adjust for your environment! The format       &lt;br /&gt;&amp;#160;&amp;#160; * of the string is host:port/service_name&lt;/font&gt;&lt;font face="Courier New"&gt;      &lt;br /&gt;&amp;#160;&amp;#160; */ &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; user = &amp;quot;hr&amp;quot;;      &lt;br /&gt;&amp;#160; passwd = &amp;quot;hr&amp;quot;;       &lt;br /&gt;&amp;#160; db = &amp;quot;oel01:1521/OEL11GR1.SAND&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; env = Environment::createEnvironment(Environment::DEFAULT); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; try      &lt;br /&gt;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con = env-&amp;gt;createConnection(user, passwd, db);       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;&amp;#160; catch (SQLException&amp;amp; ex)       &lt;br /&gt;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; ex.getMessage(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; exit(EXIT_FAILURE);      &lt;br /&gt;&amp;#160; }       &lt;br /&gt;} &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Employees::~Employees()      &lt;br /&gt;{       &lt;br /&gt;&amp;#160; env-&amp;gt;terminateConnection (con); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; Environment::terminateEnvironment (env);      &lt;br /&gt;} &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;void Employees::List()      &lt;br /&gt;{       &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160;&amp;#160; * simple test method to select data from       &lt;br /&gt;&amp;#160;&amp;#160; * the employees table and display the results       &lt;br /&gt;&amp;#160;&amp;#160; */ &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; Statement *stmt = NULL;      &lt;br /&gt;&amp;#160; ResultSet *rs = NULL;       &lt;br /&gt;&amp;#160; string sql = &amp;quot;select employee_id, first_name, last_name &amp;quot; \       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;from employees order by last_name, first_name&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; try      &lt;br /&gt;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; stmt = con-&amp;gt;createStatement(sql);       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;&amp;#160; catch (SQLException&amp;amp; ex)       &lt;br /&gt;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; ex.getMessage();       &lt;br /&gt;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; if (stmt)      &lt;br /&gt;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; try       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; stmt-&amp;gt;setPrefetchRowCount(32); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; rs = stmt-&amp;gt;executeQuery();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; catch (SQLException&amp;amp; ex)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; ex.getMessage();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; if (rs)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; setw(8) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; &amp;quot;ID&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; setw(22) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; &amp;quot;FIRST NAME&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; setw(27) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; &amp;quot;LAST NAME&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; endl;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; setw(8) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; &amp;quot;======&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; setw(22) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; &amp;quot;====================&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; setw(27) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; &amp;quot;=========================&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; endl; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; while (rs-&amp;gt;next()) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; setw(8) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; rs-&amp;gt;getString(1)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; setw(22) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; (rs-&amp;gt;isNull(2) ? &amp;quot;n/a&amp;quot; : rs-&amp;gt;getString(2))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; setw(27) &amp;lt;&amp;lt; left &amp;lt;&amp;lt; rs-&amp;gt;getString(3)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&amp;lt; endl;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cout &amp;lt;&amp;lt; endl; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; stmt-&amp;gt;closeResultSet(rs);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; con-&amp;gt;terminateStatement(stmt);      &lt;br /&gt;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Before you can build the sample, you need to add the OCCI library to the input list for the linker:&lt;/p&gt;  &lt;p&gt;Select Project –&amp;gt; OCCITest Properties... from the menu (substitute your project name if different)&lt;/p&gt;  &lt;p&gt;Expand Configuration Properties node, expand Linker node, select Input item, enter &amp;quot;oraocci11d.lib&amp;quot; for a debug build or &amp;quot;oraocci11.lib&amp;quot; for a release build.&lt;/p&gt;  &lt;p&gt;Select Build –&amp;gt; Build Solution from the menu to build the solution. If everything is setup correctly, there should be no errors during the build. If you receive errors, investigate and correct them.&lt;/p&gt;  &lt;p&gt;Executing the sample should result in output as follows:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;ID&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FIRST NAME&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LAST NAME      &lt;br /&gt;======&amp;#160; ====================&amp;#160; =========================       &lt;br /&gt;174&amp;#160;&amp;#160;&amp;#160;&amp;#160; Ellen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Abel       &lt;br /&gt;166&amp;#160;&amp;#160;&amp;#160;&amp;#160; Sundar&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Ande       &lt;br /&gt;130&amp;#160;&amp;#160;&amp;#160;&amp;#160; Mozhe&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Atkinson       &lt;br /&gt;105&amp;#160;&amp;#160;&amp;#160;&amp;#160; David&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Austin       &lt;br /&gt;204&amp;#160;&amp;#160;&amp;#160;&amp;#160; Hermann&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Baer       &lt;br /&gt;116&amp;#160;&amp;#160;&amp;#160;&amp;#160; Shelli&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Baida       &lt;br /&gt;167&amp;#160;&amp;#160;&amp;#160;&amp;#160; Amit&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Banda       &lt;br /&gt;172&amp;#160;&amp;#160;&amp;#160;&amp;#160; Elizabeth&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Bates&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;[ snip ]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;120&amp;#160;&amp;#160;&amp;#160;&amp;#160; Matthew&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Weiss      &lt;br /&gt;200&amp;#160;&amp;#160;&amp;#160;&amp;#160; Jennifer&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Whalen       &lt;br /&gt;149&amp;#160;&amp;#160;&amp;#160;&amp;#160; Eleni&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Zlotkey &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;ENTER to continue...&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If you are new to using OCCI on Windows with Visual Studio, perhaps the above will be helpful in getting started!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-4448777685595550400?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/4448777685595550400/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/07/getting-started-with-occi-windows.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/4448777685595550400?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/4448777685595550400?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/um2PZGtGvZI/getting-started-with-occi-windows.html" title="Getting Started with OCCI (Windows Version)" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/07/getting-started-with-occi-windows.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUGRn49fip7ImA9WxJWFE8.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-4116721180500794626</id><published>2009-06-18T18:10:00.005-04:00</published><updated>2009-06-19T11:10:27.066-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-19T11:10:27.066-04:00</app:edited><title>Microsoft To Deprecate System.Data.OracleClient</title><content type="html">I found the following to be an interesting announcement:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.msdn.com/adonet/archive/2009/06/15/system-data-oracleclient-update.aspx" target="_blank"&gt;System.Data.OracleClient Update&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It looks like Microsoft have decided to deprecate System.Data.OracleClient beginning with the .NET 4.0 release.&lt;br /&gt;&lt;br /&gt;Of course, I'm more than a little biased when it comes to anything related to Oracle.&lt;br /&gt;&lt;br /&gt;For more information and to download ODP.NET, please see the &lt;a href="http://www.oracle.com/technology/tech/windows/odpnet/index.html" target="_blank"&gt;Oracle Data Provider for .NET&lt;/a&gt; center on Oracle Technology Network (OTN).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-4116721180500794626?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/4116721180500794626/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/06/microsoft-to-deprecate.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/4116721180500794626?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/4116721180500794626?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/Os-vknuHW8E/microsoft-to-deprecate.html" title="Microsoft To Deprecate System.Data.OracleClient" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/06/microsoft-to-deprecate.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0ENR3s_fyp7ImA9WxJVEkU.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-1187435699725708153</id><published>2009-05-30T22:25:00.002-04:00</published><updated>2009-06-29T11:34:56.547-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-29T11:34:56.547-04:00</app:edited><title>Oracle Pro*C on Windows with Express Edition Products</title><content type="html">&lt;p&gt;NOTE: I have edited the intro text here from the original source as a result of some discussions I've had. These discussions are ongoing so I can't post the results as of yet. (3-June-2009 approximately 5:00 PM).&lt;/p&gt;  &lt;p&gt;I thought I would take an introductory look at using the &lt;a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28427/toc.htm" target="_blank"&gt;Oracle Pro*C precompiler&lt;/a&gt; using Express Edition products. Here are the components I will use for this purpose (links valid at time of posting):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Oracle Database 10g Express Edition (available &lt;a href="http://www.oracle.com/technology/software/products/database/index.html" target="_blank"&gt;here&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;Oracle Enterprise Linux (available &lt;a href="http://edelivery.oracle.com/linux" target="_blank"&gt;here&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;Oracle Instant Client 11.1.0.7 Packages for Microsoft Windows 32-bit (available &lt;a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html" target="_blank"&gt;here&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;&amp;#160;&amp;#160;&amp;#160; Instant Client Package – Basic &lt;/li&gt;    &lt;li&gt;&amp;#160;&amp;#160;&amp;#160; Instant Client Package – SDK &lt;/li&gt;    &lt;li&gt;&amp;#160;&amp;#160;&amp;#160; Instant Client Package – Precompiler &lt;/li&gt;    &lt;li&gt;&amp;#160;&amp;#160;&amp;#160; Instant Client Package - SQL*Plus &lt;/li&gt;    &lt;li&gt;Microsoft Windows XP Professional 32-bit with Service Pack 3 &lt;/li&gt;    &lt;li&gt;Microsoft Visual C++ 2008 Express Edition (available &lt;a href="http://www.microsoft.com/express/product/" target="_blank"&gt;here&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;Windows SDK for Windows Server 2008 and .NET Framework 3.5 (available &lt;a href="http://blogs.msdn.com/windowssdk/archive/2008/02/07/windows-sdk-rtms.aspx" target="_blank"&gt;here&lt;/a&gt;) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For the purposes of this discussion you will need to have already installed (or have access to) Oracle Database with the HR sample schema. You will also need to have installed Visual C++ 2008 Express Edition and the Windows SDK on the machine you will use as your development machine. For a walkthrough of installing Visual C++ 2008 Express Edition and the Windows SDK, please see this &lt;a href="http://blogs.msdn.com/windowssdk/archive/2008/02/22/using-visual-c-2008-express-with-the-windows-sdk-detailed-version.aspx" target="_blank"&gt;link&lt;/a&gt;. Note that even though the SDK seems to be only for Windows Server 2008 (based on the name) it is supported on XP, Vista, and Windows Server.&lt;/p&gt;  &lt;p&gt;In my environment I have installed Oracle Database 10g Express Edition on a host running Oracle Enterprise Linux. The host name is &amp;quot;oel02&amp;quot; (not especially clever, I realize). The Windows XP machine that I will use as the development machine is named &amp;quot;chepstow&amp;quot; (perhaps marginally more clever) and Visual C++ Express Edition and the Windows SDK are already installed. I have downloaded the four Instant Client packages listed above to the &amp;quot;c:\temp&amp;quot; directory on chepstow. The SQL*Plus package is not required; however, I find it convenient so I always install it. So, since I already have a database server and the Microsoft tools are installed, all that remains is to install the Instant Client packages.&lt;/p&gt;  &lt;h3&gt;Installing the Instant Client Packages&lt;/h3&gt;  &lt;p&gt;It is incredibly easy to install the Instant Client packages – simply unzip them! I chose to unzip them (on chepstow, my development machine) to the &amp;quot;c:\&amp;quot; directory and this created a new &amp;quot;c:\instantclient_11_1&amp;quot; directory and various sub-directories. I then added the following two directories to the system path:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;C:\instantclient_11_1 &lt;/li&gt;    &lt;li&gt;C:\instantclient_11_1\sdk&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;NOTE: I added the two directories to the beginning of the system path and had no other Oracle products installed. See comments for more information about this. (Added 29 June 2009 approximately 11:30 AM)&lt;/p&gt;  &lt;h3&gt;Setting up the Pro*C Configuration File&lt;/h3&gt;  &lt;p&gt;I know it is easy to skip reading a README file, but it is important that you do read the PRECOMP_README file in the Instant Client root directory. Pro*C will, by default, look for a configuration file named &amp;quot;pcscfg.cfg&amp;quot; when it is invoked. In the environment that I have created (default installs of all products) Pro*C will want to find this file in the &amp;quot;c:\instantclient_11_1\precomp\admin&amp;quot; directory. However, if you look at your install (if you have done the same as me) you will notice there is no such directory! Therefore you should create this directory (&amp;quot;c:\instantclient_11_1\precomp\admin&amp;quot;). You should then copy the &amp;quot;pcscfg.cfg&amp;quot; file from the &amp;quot;c:\instantclient_11_1\sdk\demo&amp;quot; directory to the &amp;quot;c:\instantclient_11_1\precomp\admin&amp;quot; directory.&lt;/p&gt;  &lt;p&gt;The &amp;quot;pcscfg.cfg&amp;quot; file will initially contain the following single line:&lt;/p&gt;  &lt;p&gt;define=(WIN32_LEAN_AND_MEAN)&lt;/p&gt;  &lt;p&gt;Below this line you add the following four lines:&lt;/p&gt;  &lt;p&gt;sys_include=C:\PROGRA~1\MICROS~1.0\VC\include\sys    &lt;br /&gt;include=C:\PROGRA~1\MICROS~3\Windows\v6.1\Include     &lt;br /&gt;include=C:\PROGRA~1\MICROS~1.0\VC\include     &lt;br /&gt;include=C:\instantclient_11_1\sdk\include&lt;/p&gt;  &lt;p&gt;Save the file and exit your editor.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Be sure to note that the directory names above are the &amp;quot;short&amp;quot; names to ensure they do not contain spaces&lt;/strong&gt;. If the directory names contain spaces this will cause problems with the Pro*C precompiler. To help &amp;quot;translate&amp;quot; the directories above, here are the long versions (be sure you do not enter these):&lt;/p&gt;  &lt;p&gt;sys_include=C:\Program Files\Microsoft Visual Studio 9.0\VC\include\sys    &lt;br /&gt;include=C:\Program Files\Microsoft SDKs\Windows\v6.1\Include     &lt;br /&gt;include=C:\Program Files\Microsoft Visual Studio 9.0\VC\include     &lt;br /&gt;include=C:\instantclient_11_1\sdk\include&lt;/p&gt;  &lt;p&gt;You can find the short names by using &amp;quot;dir /x&amp;quot; in a command-prompt window.&lt;/p&gt;  &lt;h3&gt;Adding Directories to Visual Studio C++ 2008 Express Edition&lt;/h3&gt;  &lt;p&gt;Next you should add the Oracle Instant Client include and library directories to Visual Studio. To do this, simply perform the following steps:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Select Tools –&amp;gt; Options to open the Options dialog &lt;/li&gt;    &lt;li&gt;Expand the &amp;quot;Projects and Solutions&amp;quot; node &lt;/li&gt;    &lt;li&gt;Click the &amp;quot;VC++ Directories&amp;quot; item &lt;/li&gt;    &lt;li&gt;Under &amp;quot;Show directories for:&amp;quot; select &amp;quot;Include files&amp;quot; &lt;/li&gt;    &lt;li&gt;Click underneath the last entry in the list (you should get a highlighted line with no text) &lt;/li&gt;    &lt;li&gt;Click the folder button to create a new line &lt;/li&gt;    &lt;li&gt;Enter &amp;quot;c:\instantclient_11_1\sdk\include&amp;quot; and press Enter &lt;/li&gt;    &lt;li&gt;Under &amp;quot;Show directories for:&amp;quot; select &amp;quot;Library files&amp;quot; &lt;/li&gt;    &lt;li&gt;Click underneath the last entry in the list (you should get a highlighted line with no text) &lt;/li&gt;    &lt;li&gt;Click the folder button to create a new line &lt;/li&gt;    &lt;li&gt;Enter &amp;quot;c:\instantclient_11_1\sdk\lib\msvc&amp;quot; and press Enter &lt;/li&gt;    &lt;li&gt;Click the OK button to save the changes &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Create a New Project&lt;/h3&gt;  &lt;p&gt;WARNING: You should create your project in a directory (and path) that has no spaces in it. If you create the project in a directory or path with spaces you will receive errors during the precompile phase. I used &amp;quot;c:\temp&amp;quot; for this example.&lt;/p&gt;  &lt;p&gt;Now create a new project in Visual Studio:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Select File –&amp;gt; New Project to open the New Project dialog &lt;/li&gt;    &lt;li&gt;Select &amp;quot;Win32&amp;quot; as the project type &lt;/li&gt;    &lt;li&gt;Select &amp;quot;Win32 Console Application&amp;quot; under &amp;quot;Templates&amp;quot; &lt;/li&gt;    &lt;li&gt;Give the project a name (I used &amp;quot;proctest&amp;quot; in keeping with my clever naming tradition) &lt;/li&gt;    &lt;li&gt;I always choose to de-select &amp;quot;Create directory for solution&amp;quot; and click OK &lt;/li&gt;    &lt;li&gt;Click the &amp;quot;Next&amp;quot; button in the application wizard &lt;/li&gt;    &lt;li&gt;Click the &amp;quot;Empty project&amp;quot; checkbox under &amp;quot;Additional options&amp;quot; &lt;/li&gt;    &lt;li&gt;Click the &amp;quot;Finish&amp;quot; button &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Create the Pro*C Source File&lt;/h3&gt;  &lt;p&gt;To create the Pro*C source file, perform the following steps:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Right-click &amp;quot;Source Files&amp;quot; and select Add –&amp;gt; New Item… from the context menu &lt;/li&gt;    &lt;li&gt;Select &amp;quot;Code&amp;quot; under &amp;quot;Visual C++&amp;quot; &lt;/li&gt;    &lt;li&gt;Select &amp;quot;C++ File (.cpp)&amp;quot; under &amp;quot;Visual Studio installed templates&amp;quot; (note that you will not actually create C++ code in this example) &lt;/li&gt;    &lt;li&gt;Give the file a name such as &amp;quot;proctest.pc&amp;quot; and click &amp;quot;Add&amp;quot; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here's the Pro*C source I used for this example (this is clearly sample code and &lt;strong&gt;lots&lt;/strong&gt; is left out!):&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;/*      &lt;br /&gt;** suppress certain warnings       &lt;br /&gt;*/       &lt;br /&gt;#ifdef WIN32       &lt;br /&gt;#define _CRT_SECURE_NO_DEPRECATE 1       &lt;br /&gt;#endif &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;#include &amp;lt;stdio.h&amp;gt;      &lt;br /&gt;#include &amp;lt;string.h&amp;gt;       &lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;       &lt;br /&gt;#include &amp;lt;sqlca.h&amp;gt;       &lt;br /&gt;#include &amp;lt;sqlda.h&amp;gt;       &lt;br /&gt;#include &amp;lt;sqlcpr.h&amp;gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;EXEC SQL BEGIN DECLARE SECTION; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;/*      &lt;br /&gt;** defines for VARCHAR lengths.       &lt;br /&gt;*/       &lt;br /&gt;#define UNAME_LEN 30       &lt;br /&gt;#define PWD_LEN&amp;#160;&amp;#160; 30       &lt;br /&gt;#define DB_LEN&amp;#160;&amp;#160;&amp;#160; 48       &lt;br /&gt;#define FNAME_LEN 32       &lt;br /&gt;#define LNAME_LEN 32 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;/*      &lt;br /&gt;** variables for the connection       &lt;br /&gt;*/       &lt;br /&gt;VARCHAR username[UNAME_LEN];       &lt;br /&gt;VARCHAR password[PWD_LEN];       &lt;br /&gt;VARCHAR dbname[DB_LEN]; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;/*      &lt;br /&gt;** variables to hold the results       &lt;br /&gt;*/       &lt;br /&gt;int ctr;       &lt;br /&gt;int empid;       &lt;br /&gt;VARCHAR fname[FNAME_LEN];       &lt;br /&gt;VARCHAR lname[LNAME_LEN]; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;EXEC SQL END DECLARE SECTION; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;/*      &lt;br /&gt;** declare error handling function       &lt;br /&gt;*/       &lt;br /&gt;void sql_error(char *msg)       &lt;br /&gt;{       &lt;br /&gt;&amp;#160; char err_msg[128];       &lt;br /&gt;&amp;#160; size_t buf_len, msg_len; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; EXEC SQL WHENEVER SQLERROR CONTINUE; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; printf(&amp;quot;\n%s\n&amp;quot;, msg);      &lt;br /&gt;&amp;#160; buf_len = sizeof (err_msg);       &lt;br /&gt;&amp;#160; sqlglm(err_msg, &amp;amp;buf_len, &amp;amp;msg_len);       &lt;br /&gt;&amp;#160; printf(&amp;quot;%.*s\n&amp;quot;, msg_len, err_msg); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; EXEC SQL ROLLBACK RELEASE; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; exit(EXIT_FAILURE);      &lt;br /&gt;} &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;void main()      &lt;br /&gt;{       &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** Copy the username into the VARCHAR.       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; strncpy((char *) username.arr, &amp;quot;hr&amp;quot;, UNAME_LEN);       &lt;br /&gt;&amp;#160; username.len = strlen(&amp;quot;hr&amp;quot;);       &lt;br /&gt;&amp;#160; username.arr[username.len] = '\0'; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; /*      &lt;br /&gt;&amp;#160; ** Copy the password.       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; strncpy((char *) password.arr, &amp;quot;hr&amp;quot;, PWD_LEN);       &lt;br /&gt;&amp;#160; password.len = strlen(&amp;quot;hr&amp;quot;);       &lt;br /&gt;&amp;#160; password.arr[password.len] = '\0'; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; /*      &lt;br /&gt;&amp;#160; ** copy the dbname (using EZCONNECT syntax)       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; strncpy((char *) dbname.arr, &amp;quot;oel02/XE&amp;quot;, DB_LEN);       &lt;br /&gt;&amp;#160; dbname.len = strlen(&amp;quot;oel02/XE&amp;quot;);       &lt;br /&gt;&amp;#160; dbname.arr[dbname.len] = '\0'; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; /*      &lt;br /&gt;&amp;#160; ** register sql_error() as the error handler.       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; EXEC SQL WHENEVER SQLERROR DO sql_error(&amp;quot;ORACLE error--\n&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; /*      &lt;br /&gt;&amp;#160; ** Connect to database.&amp;#160; Will call sql_error()       &lt;br /&gt;&amp;#160; ** if an error occurs when connecting.       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbname; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; printf(&amp;quot;\nConnected to ORACLE as user: %s\n\n&amp;quot;, username.arr);      &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** simple select statement       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; EXEC SQL DECLARE emps CURSOR FOR       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; SELECT&amp;#160;&amp;#160; employee_id,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; first_name,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; last_name       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; FROM&amp;#160;&amp;#160;&amp;#160;&amp;#160; employees       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ORDER BY last_name,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; first_name; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; /*      &lt;br /&gt;&amp;#160; ** open the cursor       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; EXEC SQL OPEN emps;       &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** when done fetching break out of the for loop       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; EXEC SQL WHENEVER NOT FOUND DO break;       &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** simple counter variable       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; ctr = 0;       &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** print a little header       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; printf(&amp;quot;Employee ID&amp;#160; First Name&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Last Name\n&amp;quot;);       &lt;br /&gt;&amp;#160; printf(&amp;quot;===========&amp;#160; ====================&amp;#160; =========================\n&amp;quot;);       &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** fetch all the rows       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; for (;;)       &lt;br /&gt;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; EXEC SQL FETCH emps into :empid, :fname, :lname;       &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /*       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ** null-terminate the string values       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; */       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; fname.arr[fname.len] = '\0';       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; lname.arr[lname.len] = '\0';       &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /*       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ** print the current values       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; */       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; printf(&amp;quot;%-13d%-22s%-25s\n&amp;quot;, empid, fname.arr, lname.arr);       &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ctr++;       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** close the cursor       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; EXEC SQL CLOSE emps;       &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** provide simple feedback on how many rows fetched       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; printf(&amp;quot;\nFetched %d employees.\n&amp;quot;, ctr); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; /*      &lt;br /&gt;&amp;#160; ** disconnect from database       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; EXEC SQL ROLLBACK WORK RELEASE;       &lt;br /&gt;      &lt;br /&gt;&amp;#160; /*       &lt;br /&gt;&amp;#160; ** have a nice day       &lt;br /&gt;&amp;#160; */       &lt;br /&gt;&amp;#160; exit(EXIT_SUCCESS);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;&amp;#160;&lt;/h3&gt;  &lt;h3&gt;Add a Reference to the Generated C Source File&lt;/h3&gt;  &lt;p&gt;The output of the Pro*C precompiler is either C or C++ source code (C in this case). However, because we are working with only a Pro*C source file we need to tell Visual Studio about the file that will be generated. To do this we add a reference to the not yet generated file:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Select Project –&amp;gt; Add New Item to open the Add New Item dialog &lt;/li&gt;    &lt;li&gt;Select &amp;quot;Code&amp;quot; under &amp;quot;Visual C++&amp;quot; &lt;/li&gt;    &lt;li&gt;Select &amp;quot;C++ File (.cpp)&amp;quot; under &amp;quot;Visual Studio installed templates&amp;quot; &lt;/li&gt;    &lt;li&gt;Type &amp;quot;proctest.c&amp;quot; in the &amp;quot;Name&amp;quot; textbox and click &amp;quot;Add&amp;quot; &lt;/li&gt;    &lt;li&gt;Next close the (empty) file after it is created &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Add the Pro*C Library File to the Project&lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;Select Project –&amp;gt; &amp;lt;project name&amp;gt; Properties… to open the Property Pages dialog &lt;/li&gt;    &lt;li&gt;Expand the &amp;quot;Configuration Properties&amp;quot; node &lt;/li&gt;    &lt;li&gt;Expand the &amp;quot;Linker&amp;quot; node &lt;/li&gt;    &lt;li&gt;Click the &amp;quot;Input&amp;quot; item &lt;/li&gt;    &lt;li&gt;In the &amp;quot;Additional Dependencies&amp;quot; type &amp;quot;orasql11.lib&amp;quot; and click &amp;quot;OK&amp;quot; to save the changes &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;Add the Custom Build Step&lt;/h3&gt;  &lt;p&gt;In order for Visual Studio to be able to invoke the Pro*C executable (proc.exe) to create the C source code file, a custom build step needs to be created:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Right-click &amp;quot;proctest.pc&amp;quot; in the Solution Explorer and select &amp;quot;Properties&amp;quot; from the context menu &lt;/li&gt;    &lt;li&gt;Select &amp;quot;Custom Build Step&amp;quot; &lt;/li&gt;    &lt;li&gt;For &amp;quot;Command Line&amp;quot; type &amp;quot;proc.exe $(ProjectDir)$(InputName).pc&amp;quot; &lt;/li&gt;    &lt;li&gt;For &amp;quot;Outputs&amp;quot; type &amp;quot;$(ProjectDir)$(InputName).c&amp;quot; &lt;/li&gt;    &lt;li&gt;Click &amp;quot;OK&amp;quot; to save the custom build step &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This step will cause Visual Studio to invoke proc.exe on the input file (proctest.pc) and create an output file called &amp;quot;proctest.c&amp;quot; which will then be compiled as normal. This is really the key step in the whole process I suppose. This custom build step is the &amp;quot;integration&amp;quot; of Pro*C into Visual Studio.&lt;/p&gt;  &lt;h3&gt;Build the Sample and Verify&lt;/h3&gt;  &lt;p&gt;All the hard work is now done and it is time to build the sample!&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Select Build –&amp;gt; Build Solution &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If all has gone well you should see output similar to the following in the output window:&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;proctest - 0 error(s), 0 warning(s)      &lt;br /&gt;========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If there are errors reported you will need to investigate and correct the cause.&lt;/p&gt;  &lt;p&gt;Upon completion of a successful build, you can execute the program and verify the results:&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;C:\temp\proctest\Debug&amp;gt;proctest &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;Connected to ORACLE as user: hr &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;Employee ID&amp;#160; First Name&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Last Name      &lt;br /&gt;===========&amp;#160; ====================&amp;#160; =========================       &lt;br /&gt;174&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Ellen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Abel       &lt;br /&gt;166&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Sundar&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Ande       &lt;br /&gt;130&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Mozhe&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Atkinson&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;[ snip ]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;120&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Matthew&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Weiss      &lt;br /&gt;200&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Jennifer&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Whalen       &lt;br /&gt;149&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Eleni&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Zlotkey &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;Fetched 107 employees. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;C:\temp\proctest\Debug&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;&amp;#160;&lt;/h3&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;Whew! That's a lot of work! As I mentioned at the beginning of this post, this is intended to be an introductory look at using Pro*C and Visual C++ 2008 Express Edition. There is, of course, much more that Pro*C can do and this simple example of selecting from the &amp;quot;employees&amp;quot; table in the &amp;quot;hr&amp;quot; schema is exactly that: a simple example. It is not intended to be a complete tutorial but perhaps it will be helpful in working with Pro*C and Visual Studio if you choose to do so. You should be able to adapt the steps here to using the &amp;quot;full&amp;quot; version of Visual Studio or Oracle Client.&lt;/p&gt;  &lt;p&gt;If you made it this far, thanks for stopping by. I hope this was helpful in some regard.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;NOTE: Some comments below were recently deleted by me at the request of the poster. I have, therefore, deleted my responses to those comments as they made no sense on their own. (1-June-2009 approximately 1:10 PM)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-1187435699725708153?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/1187435699725708153/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/05/oracle-proc-on-windows-with-express.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/1187435699725708153?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/1187435699725708153?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/gA_VUZhTjOg/oracle-proc-on-windows-with-express.html" title="Oracle Pro*C on Windows with Express Edition Products" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/05/oracle-proc-on-windows-with-express.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEADSHo-fyp7ImA9WxVbFkQ.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-4424469073421254049</id><published>2009-03-30T20:51:00.001-04:00</published><updated>2009-04-02T14:26:19.457-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-02T14:26:19.457-04:00</app:edited><title>jmp'ing around Win64 with ml64.exe and Assembly Language</title><content type="html">&lt;p&gt;I've been fascinated by (and interested in) assembly language for a number of years. I fondly remember my &amp;quot;&lt;a title="Peter Norton Assembly book on Amazon.com" href="http://www.amazon.com/Assembly-Language-Primer-Personal-Computer/dp/0136619010" target="_blank"&gt;Peter Norton Assembly&lt;/a&gt;&amp;quot; book and wish I hadn't sent it to a better home several years ago. But, hey, it was a major moving of house and I had to have as few items as possible. The sacrifices we make…&lt;/p&gt;  &lt;p&gt;Anyway, I had some spare time this past weekend and decided to try and see if I could get a simple 64-bit assembly language program working under Win64. My goal was to write some text to a console window and exit without destroying my entire system. I managed to succeed in that endeavor and had a bit of fun along the way. My wife thinks I have a bizarre definition of fun. If you continue to read the rest of this post keep in mind I said I was &amp;quot;interested&amp;quot; in assembly. By no means is this intended to be a tutorial or guide in writing efficient and professional assembly! As the comments in the code indicate, there was no attempt at optimization, etc!&lt;/p&gt;  &lt;p&gt;A couple of links that I ran across and found helpful (Links accurate as of today. Who knows what the future may bring?):&lt;/p&gt;  &lt;p&gt;- Matt Pietrek's X64 Primer column from the May 2006 MSDN Magazine found &lt;a title="Matt Pietrek&amp;#39;s X64 Primer column from MSDN" href="http://msdn.microsoft.com/en-us/magazine/cc300794.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;- Raymond Chen's Blog (The Old New Thing) posting entitled &amp;quot;The History of Calling Conventions, Part 5: AMD64&amp;quot; found &lt;a title="Raymond Chen&amp;#39;s The Old New Thing" href="http://blogs.msdn.com/oldnewthing/archive/2004/01/14/58579.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In order to make the code just a tiny bit more interesting I decided to call the &amp;quot;cpuid&amp;quot; function to get the Vendor ID from the processor and write that out as well as some static text. Information on the &amp;quot;cpuid&amp;quot; function is available in pdf format on both the &lt;a title="Intel CPUID Instruction PDF" href="http://www.intel.com/Assets/PDF/appnote/241618.pdf" target="_blank"&gt;Intel&lt;/a&gt; and &lt;a title="AMD CPUID Instruction PDF" href="http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25481.pdf" target="_blank"&gt;AMD&lt;/a&gt; websites. One thing that I found funny is that the 4 byte chunks (of which there are 3) that make up the output of the Vendor ID request from the &amp;quot;cpuid&amp;quot; function are stored in the registers in an &amp;quot;out of order&amp;quot; fashion. Look at the code below that gets the chunks from the registers and you'll see what I mean (I hope).&lt;/p&gt;  &lt;h3&gt;My First-Ever 64-bit Assembly Language Program With Comments and Everything&lt;/h3&gt;  &lt;p&gt;NOTE: Edits made per comment(s)&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; a (very) simple x64 masm (ml64.exe) demo that calls the cpuid function      &lt;br /&gt;; and writes the results to a console window. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; this is just an experiment and is likely not very good assembly code      &lt;br /&gt;; for one thing there is no attempt at optimization (like removing duplicate       &lt;br /&gt;; sections of code). &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; args are passed in registers as follows:      &lt;br /&gt;; RCX: 1st integer argument       &lt;br /&gt;; RDX: 2nd integer argument       &lt;br /&gt;; R8: 3rd integer argument       &lt;br /&gt;; R9: 4th integer argument       &lt;br /&gt;; the stack is used for args beyond 4 (after space reserved for first 4)       &lt;br /&gt;; this reserved space on the stack for first 4 arguments is the       &lt;br /&gt;; &amp;quot;register parameter stack area&amp;quot; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; unlike win32 the caller is responsible for cleaning the stack rather than      &lt;br /&gt;; the callee &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; win api functions that are called below &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;extrn GetStdHandle : proc      &lt;br /&gt;extrn WriteFile&amp;#160;&amp;#160;&amp;#160; : proc       &lt;br /&gt;extrn lstrlen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : proc       &lt;br /&gt;extrn ExitProcess&amp;#160; : proc &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; the variables used in the main code below such as the text to write &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;.data      &lt;br /&gt;hFile&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; qword 0       &lt;br /&gt;msglen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dword 0       &lt;br /&gt;BytesWritten dword 0       &lt;br /&gt;supp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; byte&amp;#160; 13, 10, 'CPUID instruction supported!', 13, 10, 0       &lt;br /&gt;nosupp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; byte&amp;#160; 13, 10, 'CPUID instruction NOT supported!', 13, 10, 0       &lt;br /&gt;vndrid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; byte&amp;#160; 13, 10, &amp;quot;The processor Vendor ID is 'xxxxxxxxxxxx'.&amp;quot;, 13, 10, 0 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; and we're off... &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;.code      &lt;br /&gt;main proc&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font face="courier new"&gt;&amp;#160; ; edited Tuesday, 31 March 2009      &lt;br /&gt;&amp;#160; ; registers that should be preserved (non-volatile)&lt;/font&gt;&lt;font face="courier new"&gt;&amp;#160; &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; rbx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register       &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; rbp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register       &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; rsi&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register       &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; rdi&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register       &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; r12&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register       &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; r13&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register       &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; r14&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register       &lt;br /&gt;&amp;#160; push&amp;#160;&amp;#160;&amp;#160; r15&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save (preserve) register&lt;/font&gt; &lt;/p&gt; &lt;font face="courier new"&gt;&amp;#160; sub rsp, 28h&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; adjust stack for local storage if needed&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; and align on a 16 byte boundary &lt;/font&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; ; get the handle for the console window to use when writing text      &lt;br /&gt;&amp;#160; ; this is used by WriteFile win api function below &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; mov ecx, -11&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; put -11 (STD_OUTPUT_HANDLE) into ecx (dword)      &lt;br /&gt;&amp;#160; call GetStdHandle&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api to get console handle       &lt;br /&gt;&amp;#160; mov hFile, rax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; move returned handle to hFile &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; ; check that the cpuid instruction is supported      &lt;br /&gt;&amp;#160; ; this is very likely supported, but here for completeness &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; ; taken from the AMD64 Architecture Programmer’s Manual      &lt;br /&gt;&amp;#160; ; Volume 3: General-Purpose and System Instructions &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; pushfq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save EFLAGS      &lt;br /&gt;&amp;#160; pop rax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; store EFLAGS in RAX       &lt;br /&gt;&amp;#160; mov rbx, rax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save in RBX for test       &lt;br /&gt;&amp;#160; xor rax, 200000h&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; toggle bit #21 (i.e. 22nd bit)       &lt;br /&gt;&amp;#160; push rax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; put result on stack       &lt;br /&gt;&amp;#160; popfq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; save changed RAX to EFLAGS       &lt;br /&gt;&amp;#160; pushfq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; push EFLAGS onto stack       &lt;br /&gt;&amp;#160; pop rax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; store EFLAGS in RAX       &lt;br /&gt;&amp;#160; cmp rax, rbx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; determine if bit #21 changed       &lt;br /&gt;&amp;#160; je no_cpuid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; cpuid not supported (bit did not change) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; ; cpuid is supported if we did not jump...      &lt;br /&gt;&amp;#160; ; so print the message that it is supported and then       &lt;br /&gt;&amp;#160; ; jump to location where it is actually performed &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; lea rcx, supp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; load address of supp text into rcx      &lt;br /&gt;&amp;#160; call lstrlen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api function to get length of text       &lt;br /&gt;&amp;#160; mov msglen, eax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; move length of string from eax to msglen &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; lea r9, BytesWritten&amp;#160; ; LPDWORD lpNumberOfBytesWritten      &lt;br /&gt;&amp;#160; mov r8d, msglen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; DWORD nNumberOfBytesToWrite       &lt;br /&gt;&amp;#160; lea rdx, supp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; LPCVOID lpBuffer       &lt;br /&gt;&amp;#160; mov rcx, hFile&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; HANDLE hFile       &lt;br /&gt;&amp;#160; call WriteFile&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api to write text to console &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; jmp do_cpuid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; jump over the no_cpuid code path &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;no_cpuid:      &lt;br /&gt;&amp;#160; lea rcx, nosupp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; load address of nosupp text into rcx       &lt;br /&gt;&amp;#160; call lstrlen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api function to get length of text       &lt;br /&gt;&amp;#160; mov msglen, eax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; move length of string from eax to msglen &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; lea r9, BytesWritten&amp;#160; ; LPDWORD lpNumberOfBytesWritten      &lt;br /&gt;&amp;#160; mov r8d, msglen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; DWORD nNumberOfBytesToWrite       &lt;br /&gt;&amp;#160; lea rdx, nosupp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; LPCVOID lpBuffer       &lt;br /&gt;&amp;#160; mov rcx, hFile&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; HANDLE hFile       &lt;br /&gt;&amp;#160; call WriteFile&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api to write text to console &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; jmp exit&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; the no support message was written, so exit &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;do_cpuid:      &lt;br /&gt;&amp;#160; lea rcx, vndrid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; load address of vndrid text into rcx       &lt;br /&gt;&amp;#160; call lstrlen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api function to get length of text       &lt;br /&gt;&amp;#160; mov msglen, eax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; move length of string from eax to msglen &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; xor eax, eax&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; 0 indicates we want the vendor id string      &lt;br /&gt;&amp;#160; cpuid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; invoke the cpuid instruction to get the string       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; the results are now in ebx, edx, and ecx &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; ; replace the 'x' placeholders with the vendor id      &lt;br /&gt;&amp;#160; lea r9, vndrid &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; mov [r9+30], ebx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; the first 4 bytes of the vendor id      &lt;br /&gt;&amp;#160; mov [r9+34], edx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; the next 4 bytes of the vendor id       &lt;br /&gt;&amp;#160; mov [r9+38], ecx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; the final 4 bytes of the vendor id &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;&amp;#160; lea r9, BytesWritten&amp;#160; ; LPDWORD lpNumberOfBytesWritten      &lt;br /&gt;&amp;#160; mov r8d, msglen&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; DWORD nNumberOfBytesToWrite       &lt;br /&gt;&amp;#160; lea rdx, vndrid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; LPCVOID lpBuffer       &lt;br /&gt;&amp;#160; mov rcx, hFile&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; HANDLE hFile       &lt;br /&gt;&amp;#160; call WriteFile&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api to write text to console &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;; edited Tuesday, 31 March 2009      &lt;br /&gt;exit:&lt;/font&gt;     &lt;br /&gt;&lt;font face="courier new"&gt;&amp;#160; add&amp;#160;&amp;#160;&amp;#160;&amp;#160; rsp, 28h&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; clean up the stack      &lt;br /&gt;      &lt;br /&gt;&lt;/font&gt;&lt;font face="courier new"&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; r15&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register      &lt;br /&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; r14&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register       &lt;br /&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; r13&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register       &lt;br /&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; r12&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register       &lt;br /&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; rdi&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register       &lt;br /&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; rsi&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register       &lt;br /&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; rbp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register       &lt;br /&gt;&amp;#160; pop&amp;#160;&amp;#160;&amp;#160;&amp;#160; rbx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; restore preserved register&amp;#160; &lt;br /&gt;      &lt;br /&gt;&lt;/font&gt;&lt;font face="courier new"&gt;&amp;#160; xor ecx, ecx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; xor ecx (set to 0) for return value      &lt;br /&gt;&amp;#160; call ExitProcess&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ; call win api to exit       &lt;br /&gt;&lt;/font&gt;&lt;font face="courier new"&gt;main endp &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;end&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The command I used to compile the above is (apologies if wrapping make it difficult to read):&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;ml64 test64.asm /link /subsystem:console /defaultlib:&amp;quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64\kernel32.lib&amp;quot; /entry:main&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;And for the moment of truth…&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;C:\My Projects\Test\ASM\test&amp;gt;test64 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;CPUID instruction supported! &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="courier new"&gt;The processor Vendor ID is 'GenuineIntel'.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Hurray! Unless you sell AMD chips then you might think 'AuthenticAMD' would look better…&lt;/p&gt;  &lt;p&gt;If you see something profoundly wrong in the above, please let me know. It's not like I am going to be churning out assembly code all of a sudden, but I would still be interested in knowing…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-4424469073421254049?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/4424469073421254049/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/03/jmp-around-win64-with-ml64exe-and.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/4424469073421254049?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/4424469073421254049?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/Sl-tadhtcCk/jmp-around-win64-with-ml64exe-and.html" title="jmp&amp;#39;ing around Win64 with ml64.exe and Assembly Language" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/03/jmp-around-win64-with-ml64exe-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQHQH4zcCp7ImA9WxVUGUk.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-8468632891705286240</id><published>2009-03-24T21:16:00.002-04:00</published><updated>2009-03-24T21:25:31.088-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-24T21:25:31.088-04:00</app:edited><title>ODP.NET Tip: Bind Variables, the BindByName Property, and PL/SQL Function Return Values</title><content type="html">&lt;p&gt;A question was posed as a follow-up to a previous post here:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://oradim.blogspot.com/2007/08/odpnet-tip-bind-variables-and.html" href="http://oradim.blogspot.com/2007/08/odpnet-tip-bind-variables-and.html"&gt;http://oradim.blogspot.com/2007/08/odpnet-tip-bind-variables-and.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The poster wanted to know if you have set BindByName to &amp;quot;true&amp;quot; for an OracleCommand object and the command text for that object calls a PL/SQL function (which of course has a return value but no name), what name should you give to the parameter object that will receive the return value? It's a good question since BindByName set to &amp;quot;true&amp;quot; implies that you've given names to your bind variables!&lt;/p&gt;  &lt;p&gt;The short answer is: It doesn't matter as it will be ignored anyway.&lt;/p&gt;  &lt;p&gt;As in The Highlander movies, with return values, there can be only one. You can set ParameterDirection to &amp;quot;ReturnValue&amp;quot; for multiple parameters, but it is an error to do so. Try it and see what errors are raised.&lt;/p&gt;  &lt;p&gt;Here's a quick little demo showing that it does not matter what name you give to the parameter that you declare as the return value.&lt;/p&gt;  &lt;p&gt;First create a simple PL/SQL function (so that there &lt;strong&gt;is&lt;/strong&gt; a return value!) like this:&lt;/p&gt;  &lt;p&gt;create or replace function subtract_numbers(p1 in number, p2 in number) return number as   &lt;br /&gt;begin    &lt;br /&gt;&amp;#160; return p1 - p2;    &lt;br /&gt;end;    &lt;br /&gt;/&lt;/p&gt;  &lt;p&gt;I've elected to do a simple bit of subtraction and this is for a reason. Since in subtraction the order of the parameters matters, it is easy to show that the parameters are being handled in the correct order. As you'll see in the sample code below, I use the values &amp;quot;48&amp;quot; and &amp;quot;2&amp;quot; so it would be obvious if the ordering were reversed.&lt;/p&gt;  &lt;p&gt;Now, here's some simple (and normal caveats about no error handling, etc. apply) bit of C# to illustrate the point:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using System;     &lt;br /&gt;using System.Data;      &lt;br /&gt;using Oracle.DataAccess.Client;      &lt;br /&gt;using Oracle.DataAccess.Types; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;class Program     &lt;br /&gt;{      &lt;br /&gt;&amp;#160; static void Main(string[] args)      &lt;br /&gt;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // adjust connect string to suit your environment      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string constr = &amp;quot;user id=hr;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;password=hr;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;data source=orademo;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;pooling=false;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;enlist=false&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // create and open connection     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; OracleConnection con = new OracleConnection(constr);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con.Open(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // create command object     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; OracleCommand cmd = con.CreateCommand();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;subtract_numbers&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.CommandType = CommandType.StoredProcedure; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // set bindbyname to true so parameters can be added     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // in any order and to illustrate what happens with a      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // return value      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.BindByName = true; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // the first input parameter to the pl/sql function     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; OracleParameter p1 = new OracleParameter();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p1.Direction = ParameterDirection.Input;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p1.OracleDbType = OracleDbType.Int64;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p1.ParameterName = &amp;quot;p1&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p1.Value = 48; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // the second input parameter to the pl/sql function     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; OracleParameter p2 = new OracleParameter();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p2.Direction = ParameterDirection.Input;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p2.OracleDbType = OracleDbType.Int64;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p2.ParameterName = &amp;quot;p2&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p2.Value = 2; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // the return parameter from the pl/sql function     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; OracleParameter p3 = new OracleParameter();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p3.Direction = ParameterDirection.ReturnValue;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p3.OracleDbType = OracleDbType.Int64;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p3.ParameterName = &amp;quot;ignored&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // add the parameters in a &amp;quot;wrong&amp;quot; order since     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // bindbyname is true -- this is key      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(p1);&amp;#160; // input #1      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(p3);&amp;#160; // return value      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(p2);&amp;#160; // input #2 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // execute the stored pl/sql code     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // write the result to the console window     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;The difference of {0} and {1} is {2}&amp;quot;,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p1.Value, p2.Value, p3.Value); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // prevent console window from closing when run from VS     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Console.Write(&amp;quot;ENTER to continue...&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Console.ReadLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // clean up      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p3.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p2.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; p1.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; cmd.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con.Dispose();      &lt;br /&gt;&amp;#160; }      &lt;br /&gt;} &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Notice how the parameters are added to the parameter collection &amp;quot;out of order&amp;quot;. This is OK since BindByName is set to &amp;quot;true&amp;quot;. You can comment out the line that sets BindByName and see an exception raised if you want. Anyway, when I execute this code, I get the expected results as follows:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;The difference of 48 and 2 is 46 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;ENTER to continue...&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;So, even though the return value parameter was added to the collection in the second position everything works as desired. Yes, but I gave it a name of &amp;quot;ignored&amp;quot; so how do we know that name is not really being used? Well there are two easy ways to find out. One, just don't give the parameter a name at all and everything should continue to execute just fine. It's easy to ignore a name that's not there! Or, two, if you are an inquisitive type, enable SQL tracing (search the web for 10046 trace -- you'll find a million hits) and see what ODP.NET actually sent to the database. Here's a snippet of a trace file from the above code (with the parameter name of &amp;quot;ignored&amp;quot; in place):&lt;/p&gt;  &lt;p&gt;PARSING IN CURSOR #2 len=54 dep=0 uid=82 oct=47 lid=82 tim=10601980885 hv=1771638930 ad='7ff39775518' sqlid='gx0kvypntk44k'   &lt;br /&gt;Begin :ret := subtract_numbers(p1=&amp;gt;:v0, p2=&amp;gt;:v2); End;    &lt;br /&gt;END OF STMT    &lt;br /&gt;PARSE #2:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=0,tim=10601980885    &lt;br /&gt;BINDS #2:    &lt;br /&gt; Bind#0    &lt;br /&gt;&amp;#160; oacdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00    &lt;br /&gt;&amp;#160; oacflg=03 fl2=1000000 frm=00 csi=00 siz=72 off=0    &lt;br /&gt;&amp;#160; kxsbbbfp=1bb2dd60&amp;#160; bln=22&amp;#160; avl=00&amp;#160; flg=05    &lt;br /&gt; Bind#1    &lt;br /&gt;&amp;#160; oacdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00    &lt;br /&gt;&amp;#160; oacflg=03 fl2=1000000 frm=00 csi=00 siz=0 off=24    &lt;br /&gt;&amp;#160; kxsbbbfp=1bb2dd78&amp;#160; bln=22&amp;#160; avl=02&amp;#160; flg=01    &lt;br /&gt;&amp;#160; value=48    &lt;br /&gt; Bind#2    &lt;br /&gt;&amp;#160; oacdty=02 mxl=22(21) mxlc=00 mal=00 scl=00 pre=00    &lt;br /&gt;&amp;#160; oacflg=03 fl2=1000000 frm=00 csi=00 siz=0 off=48    &lt;br /&gt;&amp;#160; kxsbbbfp=1bb2dd90&amp;#160; bln=22&amp;#160; avl=02&amp;#160; flg=01    &lt;br /&gt;&amp;#160; value=2&lt;/p&gt;  &lt;p&gt;See how ODP.NET generated a little anonymous block and substituted &amp;quot;ret&amp;quot; for the return value parameter? You should see the same thing even if there is no name given to the return parameter. You can also clearly see how the input parameter names are associated with the input values.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-8468632891705286240?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/8468632891705286240/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/03/odpnet-tip-bind-variables-bindbyname.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/8468632891705286240?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/8468632891705286240?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/gTMpdheuRXQ/odpnet-tip-bind-variables-bindbyname.html" title="ODP.NET Tip: Bind Variables, the BindByName Property, and PL/SQL Function Return Values" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/03/odpnet-tip-bind-variables-bindbyname.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIBQnc-cCp7ImA9WxVUEEg.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-2231389353360815968</id><published>2009-03-14T14:14:00.001-04:00</published><updated>2009-03-14T14:15:53.958-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-14T14:15:53.958-04:00</app:edited><title>HotSos Symposium 2009 Materials</title><content type="html">&lt;p&gt;The paper and all sample code from my HotSos Symposium 2009 presentation entitled "Instrumented Code Is Better Code" is available as a single .zip file. To download the .zip file, click &lt;a title="Instrumented Code Is Better Code Download" href="http://apex.oracle.com/pls/otn/CHESHAMDBS.get_hotsos_2009_materials"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-2231389353360815968?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/2231389353360815968/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/03/hotsos-symposium-2009-materials.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/2231389353360815968?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/2231389353360815968?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/IxNe7q4G8gg/hotsos-symposium-2009-materials.html" title="HotSos Symposium 2009 Materials" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/03/hotsos-symposium-2009-materials.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08FRX08cSp7ImA9WxVRFEU.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-2082209460397131642</id><published>2009-01-20T17:16:00.001-05:00</published><updated>2009-01-20T17:16:54.379-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-20T17:16:54.379-05:00</app:edited><title>Oracle ACE Director No More</title><content type="html">&lt;p&gt;Today marks my first day back at Oracle Corp. and I find myself in the same boat as Kevin Closson. I'm not saying I'm sitting in the same section mind you, just that I am in the same boat as regards to &lt;a href="http://kevinclosson.wordpress.com/2009/01/08/oracle-ace-or-oracle-dunceerr-i-mean-deuce/" target="_blank"&gt;no longer being eligible for the Oracle ACE program&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I think I have removed the ACE and Director logos as well as text from the appropriate spots, but if I missed a place or two, well, I'll try to get them removed too!&lt;/p&gt;  &lt;p&gt;As Kevin says, at least there is that vest thing...&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-2082209460397131642?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/2082209460397131642/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/01/oracle-ace-director-no-more.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/2082209460397131642?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/2082209460397131642?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/jwnGOetc9XU/oracle-ace-director-no-more.html" title="Oracle ACE Director No More" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/01/oracle-ace-director-no-more.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYBRn4zeSp7ImA9WxVSFk4.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-3595084262980621570</id><published>2009-01-10T20:09:00.001-05:00</published><updated>2009-01-10T20:09:17.081-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-10T20:09:17.081-05:00</app:edited><title>So, back to Oracle then?</title><content type="html">&lt;p&gt;Next week will mark the last week at my current location as I have recently decided to return to Oracle Corp.&lt;/p&gt;  &lt;p&gt;I will be going back to the world of C and UNIX derivatives having accepted a position on the non-Windows PLBDE team.&lt;/p&gt;  &lt;p&gt;It's hard to say what that will mean for the blog here, which has been pretty quiet from my side as of late to be sure, but perhaps I will branch out from my typical topics of ODP.NET and/or Oracle on Windows. We'll see.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-3595084262980621570?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/3595084262980621570/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2009/01/so-back-to-oracle-then.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3595084262980621570?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3595084262980621570?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/noQ_JmeWXH4/so-back-to-oracle-then.html" title="So, back to Oracle then?" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://oradim.blogspot.com/2009/01/so-back-to-oracle-then.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEAAQXYzcCp7ImA9WxRVEU0.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-5335462373015089876</id><published>2008-11-07T20:12:00.001-05:00</published><updated>2008-11-07T20:12:20.888-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-07T20:12:20.888-05:00</app:edited><title>HotSos Symposium 2009</title><content type="html">&lt;p&gt;The &lt;a href="http://www.hotsos.com/sym09.html"&gt;HotSos Symposium 2009&lt;/a&gt; is coming up soon. For 2009, the symposium runs from 8 March through to 12 March. This is always one of my favorite conferences of the year, and I will be presenting on &amp;quot;Instrumented Code is Better Code&amp;quot;.&lt;/p&gt;  &lt;p&gt;The conference, as always, features a &lt;a href="http://www.hotsos.com/sym_speakers.html"&gt;fantastic line-up&lt;/a&gt; this year. I'm particularly interested in the keynote being delivered by &lt;a href="http://www.hotsos.com/sym_keynote.html"&gt;Chris Date&lt;/a&gt;. In addition, &lt;a href="http://jonathanlewis.wordpress.com/all-postings"&gt;Jonathan Lewis&lt;/a&gt; will be delivering the training day material. If you have the opportunity to attend this conference, I highly recommend it.&lt;/p&gt;  &lt;p&gt;Now, I'd better get to work!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-5335462373015089876?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/5335462373015089876/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/11/hotsos-symposium-2009.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/5335462373015089876?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/5335462373015089876?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/P7ZssR7GP7g/hotsos-symposium-2009.html" title="HotSos Symposium 2009" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/11/hotsos-symposium-2009.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMCR3czeSp7ImA9WxRXEk0.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-1138103105485638179</id><published>2008-10-16T20:27:00.001-04:00</published><updated>2008-10-16T20:31:06.981-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-16T20:31:06.981-04:00</app:edited><title>Does ODP.NET Send Data to the Server for Out PL/SQL Parameters?</title><content type="html">&lt;p&gt;I was recently discussing (and by that I mean trading emails) with a friend about an interesting behavior observed when using PL/SQL &amp;quot;out&amp;quot; VARCHAR2 variables with ODP.NET - in this case it looks like ODP.NET is sending data &lt;em&gt;from&lt;/em&gt; the client and &lt;em&gt;to&lt;/em&gt; the server for a parameter that is defined as &amp;quot;out&amp;quot; in a PL/SQL procedure. This seems like strange behavior and I don't have a good answer as to why data would be sent from the client to the server for a parameter declared as an &amp;quot;out&amp;quot; parameter.&lt;/p&gt;  &lt;p&gt;In any case here's a quick and dirty sample that illustrates this (on my test system anyway):&lt;/p&gt;  &lt;h3&gt;PL/SQL Procedure&lt;/h3&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;create or replace procedure ptest (p_vc out varchar2) as     &lt;br /&gt;begin      &lt;br /&gt;&amp;#160; p_vc := rpad ('a', 31999, 'a');      &lt;br /&gt;end;      &lt;br /&gt;/&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;C# Sample Console&lt;/h3&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using System;     &lt;br /&gt;using System.Data;      &lt;br /&gt;using System.Data.OracleClient;      &lt;br /&gt;using Oracle.DataAccess.Client;      &lt;br /&gt;using Oracle.DataAccess.Types; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;namespace Miscellaneous {     &lt;br /&gt;&amp;#160; class Program {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; static void Main(string[] args) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string constr = &amp;quot;User Id=markwill;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Password=oracle;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Data Source=orademo;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Pooling=false;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Enlist=false&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TestODP(constr); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TestMS(constr); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.Write(&amp;quot;ENTER to continue...&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.ReadLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; static void TestODP(string constr) {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Oracle.DataAccess.Client.OracleConnection con = new Oracle.DataAccess.Client.OracleConnection(constr);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Open(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Oracle.DataAccess.Client.OracleCommand cmd = con.CreateCommand(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;alter session set events '10046 trace name context forever, level 12'&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;ptest&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandType = CommandType.StoredProcedure;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.BindByName = true; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Oracle.DataAccess.Client.OracleParameter p_vc = new Oracle.DataAccess.Client.OracleParameter();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.ParameterName = &amp;quot;p_vc&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.OracleDbType = OracleDbType.Varchar2;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.Size = 32000;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.Direction = ParameterDirection.Output; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(p_vc); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;p_vc = {0}&amp;quot;, p_vc.Value); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.Dispose();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; static void TestMS(string constr) {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Data.OracleClient.OracleConnection con = new System.Data.OracleClient.OracleConnection(constr);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Open(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Data.OracleClient.OracleCommand cmd = con.CreateCommand(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;alter session set events '10046 trace name context forever, level 12'&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;ptest&amp;quot;;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandType = CommandType.StoredProcedure; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Data.OracleClient.OracleParameter p_vc = new System.Data.OracleClient.OracleParameter();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.ParameterName = &amp;quot;p_vc&amp;quot;;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.OracleType = OracleType.LongVarChar;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.Size = 32000;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_vc.Direction = ParameterDirection.Output; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(p_vc); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;p_vc = {0}&amp;quot;, p_vc.Value); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Dispose();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This is pretty straight-forward and simply opens a connection, enables Extended SQL Tracing via setting event 10046, creates a parameter for the output value, and calls the stored procedure.&lt;/p&gt;  &lt;p&gt;Looking at the respective trace files I find this for the ODP.NET test:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;PARSING IN CURSOR #4 len=28 dep=0 uid=88 oct=47 lid=88 tim=9306513611 hv=1721325005 ad='7ff2eca8c38' sqlid='dk08s2dm9kpfd'     &lt;br /&gt;Begin ptest(p_vc=&amp;gt;:v0); End;      &lt;br /&gt;END OF STMT      &lt;br /&gt;PARSE #4:c=0,e=798,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=9306513607      &lt;br /&gt;&lt;strong&gt;WAIT #4: nam='SQL*Net more data from client' ela= 48 driver id=1413697536 #bytes=44 p3=0 obj#=-1 tim=9306513786       &lt;br /&gt;WAIT #4: nam='SQL*Net more data from client' ela= 7 driver id=1413697536 #bytes=24 p3=0 obj#=-1 tim=9306513827        &lt;br /&gt;WAIT #4: nam='SQL*Net more data from client' ela= 171 driver id=1413697536 #bytes=4 p3=0 obj#=-1 tim=9306514027        &lt;br /&gt;WAIT #4: nam='SQL*Net more data from client' ela= 28 driver id=1413697536 #bytes=49 p3=0 obj#=-1 tim=9306514085        &lt;br /&gt;&lt;/strong&gt;BINDS #4:      &lt;br /&gt; Bind#0      &lt;br /&gt;&amp;#160; oacdty=01 mxl=32767(32000) mxlc=32000 mal=00 scl=00 pre=00      &lt;br /&gt;&amp;#160; oacflg=03 fl2=1000010 frm=01 csi=178 siz=32767 off=0      &lt;br /&gt;&amp;#160; kxsbbbfp=1c3d8000&amp;#160; bln=32767&amp;#160; avl=32000&amp;#160; flg=05      &lt;br /&gt;&amp;#160; &lt;strong&gt;value=&amp;quot;&amp;#196;6&amp;#191;&amp;#191;&amp;quot;...&lt;/strong&gt;      &lt;br /&gt;WAIT #4: nam='SQL*Net message to client' ela= 3 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=9306514373      &lt;br /&gt;WAIT #4: nam='SQL*Net more data to client' ela= 49 driver id=1413697536 #bytes=8216 p3=0 obj#=-1 tim=9306514456      &lt;br /&gt;WAIT #4: nam='SQL*Net more data to client' ela= 23 driver id=1413697536 #bytes=8192 p3=0 obj#=-1 tim=9306514507      &lt;br /&gt;WAIT #4: nam='SQL*Net more data to client' ela= 271 driver id=1413697536 #bytes=8192 p3=0 obj#=-1 tim=9306514805      &lt;br /&gt;EXEC #4:c=0,e=1139,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,tim=9306514839      &lt;br /&gt;XCTEND rlbk=0, rd_only=1      &lt;br /&gt;WAIT #4: nam='SQL*Net message from client' ela= 69517 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=9306584449      &lt;br /&gt;XCTEND rlbk=0, rd_only=1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;As you can see there are several &amp;quot;SQL*Net more data from client&amp;quot; messages. Of course, these are followed by the sending of data to the client.&lt;/p&gt;  &lt;p&gt;Now here is the relevant portion of the trace file for the MS provider test:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;PARSING IN CURSOR #3 len=30 dep=0 uid=88 oct=47 lid=88 tim=9306615423 hv=1003497284 ad='7ff27721950' sqlid='42zzxzhxx09u4'     &lt;br /&gt;begin ptest(p_vc=&amp;gt;:p_vc); end;      &lt;br /&gt;END OF STMT      &lt;br /&gt;PARSE #3:c=0,e=1507,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=9306615420      &lt;br /&gt;BINDS #3:      &lt;br /&gt; Bind#0      &lt;br /&gt;&amp;#160; oacdty=01 mxl=32767(32000) mxlc=32000 mal=00 scl=00 pre=00      &lt;br /&gt;&amp;#160; oacflg=03 fl2=1000010 frm=01 csi=178 siz=32767 off=0      &lt;br /&gt;&amp;#160; kxsbbbfp=1c3d8000&amp;#160; bln=32767&amp;#160; avl=00&amp;#160; flg=05      &lt;br /&gt;WAIT #3: nam='SQL*Net message to client' ela= 3 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=9306615726      &lt;br /&gt;WAIT #3: nam='SQL*Net more data to client' ela= 69 driver id=1413697536 #bytes=8216 p3=0 obj#=-1 tim=9306615822      &lt;br /&gt;WAIT #3: nam='SQL*Net more data to client' ela= 18 driver id=1413697536 #bytes=8192 p3=0 obj#=-1 tim=9306615861      &lt;br /&gt;WAIT #3: nam='SQL*Net more data to client' ela= 200 driver id=1413697536 #bytes=8192 p3=0 obj#=-1 tim=9306616081      &lt;br /&gt;EXEC #3:c=0,e=612,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,tim=9306616112      &lt;br /&gt;XCTEND rlbk=0, rd_only=1      &lt;br /&gt;WAIT #3: nam='SQL*Net message from client' ela= 60351 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=9306676628      &lt;br /&gt;XCTEND rlbk=0, rd_only=1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;In this case there are no messages from the client and in the bind section there is no &amp;quot;value=&amp;quot; element.&lt;/p&gt;  &lt;p&gt;An interesting wrinkle is that if I set the parameter direction to &amp;quot;ParameterDirection.InputOutput&amp;quot; using ODP.NET I do not observe the sending of data from the client.&lt;/p&gt;  &lt;p&gt;Why, I wonder, does ODP.NET send data to the server for an output parameter? Ideas? Similar behavior observed?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-1138103105485638179?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/1138103105485638179/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/10/does-odpnet-send-data-to-server-for-out.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/1138103105485638179?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/1138103105485638179?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/zN8qcbTgncU/does-odpnet-send-data-to-server-for-out.html" title="Does ODP.NET Send Data to the Server for Out PL/SQL Parameters?" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/10/does-odpnet-send-data-to-server-for-out.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04FRnozcCp7ImA9WxRRE0o.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-946657655432619846</id><published>2008-09-25T15:40:00.004-04:00</published><updated>2008-09-25T15:45:17.488-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-09-25T15:45:17.488-04:00</app:edited><title>Oracle Open World 2008 Podcast</title><content type="html">I've never really been a prolific blogger and the "interruption" of OOW 2008 has definitely impacted this. However, my podcast with Tom Haunert of Oracle Magazine is now available at the following location:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.oracle.com/technology/syndication/magcasts/index.html"&gt;Oracle Magazine Feature Casts&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The title of the podcast is:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://streaming.oracle.com/ebn/podcasts/omag/6976727_Mark_Williams_092308.mp3"&gt;Origins of a .NET Developer&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-946657655432619846?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/946657655432619846/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/09/oracle-open-world-2008-podcast.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/946657655432619846?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/946657655432619846?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/uZmq2yL__Co/oracle-open-world-2008-podcast.html" title="Oracle Open World 2008 Podcast" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/09/oracle-open-world-2008-podcast.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkMMRHczfyp7ImA9WxdaGEU.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-2510606966683257326</id><published>2008-08-27T21:54:00.001-04:00</published><updated>2008-08-27T21:54:45.987-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-27T21:54:45.987-04:00</app:edited><title>My Current Development Environment</title><content type="html">&lt;p&gt;Whilst I am primarily a DBA during the day, one of the things that I really enjoy about my current engagement is that it has given me the opportunity to dip my toes back in the development pool a bit. I was describing my current development environment to a friend recently and this person was shocked by the details. I realize that in this day and age of code spitters (term coined by Jeff Richter?) and &amp;quot;click through the wizard for instant coding success&amp;quot; sorts of activities that this environment is something of an anachronism.&lt;/p&gt;  &lt;p&gt;Without further ado, the o/s:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;$ uname -a     &lt;br /&gt;HP-UX zzz B.11.31 U ia64 4131905082 unlimited-user license&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;My &amp;quot;IDE&amp;quot;:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;$ which vi     &lt;br /&gt;/usr/bin/vi&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;And the compiler:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;$ gcc -v     &lt;br /&gt;Using built-in specs.      &lt;br /&gt;Target: ia64-hp-hpux11.31      &lt;br /&gt;Configured with: ../gcc/configure      &lt;br /&gt;Thread model: posix      &lt;br /&gt;gcc version 4.2.1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Yes, I actually have to do things like create a Makefile in such an environment!&lt;/p&gt;  &lt;p&gt;Joking aside though, one of the things that I firmly believe is that instrumented code is better code. One of the characteristics of this kind of development environment, I feel, is that it really encourages strongly instrumenting the code. Yes, in some circumstances I could use the gdb debugger, but building proper instrumentation into the code and offering a simple switch to enable it (yes, it is in the release build) works very nicely.&lt;/p&gt;  &lt;p&gt;Another thing that some people might find &amp;quot;weird&amp;quot; about this application is that it is a database application (Oracle of course) that contains absolutely no SQL statements. Really. It is a &amp;quot;thick database&amp;quot; application (Toon Koppelaars term?). That is, there are many statements like &amp;quot;begin package.procedure...; end;&amp;quot; in the code. All the real work is done using PL/SQL packages (and bodies) in the database.&lt;/p&gt;  &lt;p&gt;As a .NET developer it is often easy to lean heavily on Visual Studio for debugging, but I think Microsoft also agrees with the &amp;quot;instrumented code is better code&amp;quot; philosophy - check out the System.Diagnostics.Trace class in the Visual Studio Combined Help Collection for more information.&lt;/p&gt;  &lt;p&gt;Lastly, if I've misappropriated any of the terms above, apologies!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-2510606966683257326?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/2510606966683257326/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/08/my-current-development-environment.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/2510606966683257326?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/2510606966683257326?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/o6Onf5KWTXc/my-current-development-environment.html" title="My Current Development Environment" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/08/my-current-development-environment.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QFRHw9eyp7ImA9WxdaFEg.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-438307703782799553</id><published>2008-08-22T21:35:00.001-04:00</published><updated>2008-08-22T21:35:15.263-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-22T21:35:15.263-04:00</app:edited><title>Oracle OpenWorld 2008 - Just Say Hi!</title><content type="html">&lt;p&gt;Just a quick note... if you happen to be coming to Oracle OpenWorld 2008 in San Francisco, I will be helping out in the .NET Hands-On Labs Monday (22 Sep) afternoon. I'll also be at the &amp;quot;&lt;a href="http://wiki.oracle.com/page/Oracle+ACE+Office+Hours+in+the+OTN+Lounge?t=anon" target="_blank"&gt;OTN ACE Office Hours&lt;/a&gt;&amp;quot; on Monday (22 Sep) as well as Thursday (25 Sep). See the link for schedules as well as the great folks who will be available. I've also been known to be around the demo grounds booth as well. Please say &amp;quot;hi&amp;quot; if you get the chance! &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-438307703782799553?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/438307703782799553/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/08/oracle-openworld-2008-just-say-hi.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/438307703782799553?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/438307703782799553?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/GDbUxQ_LA0o/oracle-openworld-2008-just-say-hi.html" title="Oracle OpenWorld 2008 - Just Say Hi!" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/08/oracle-openworld-2008-just-say-hi.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8NRHo8fip7ImA9WxdVGUk.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-5170977328607724173</id><published>2008-07-24T19:41:00.001-04:00</published><updated>2008-07-24T19:41:35.476-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-07-24T19:41:35.476-04:00</app:edited><title>Creating a Windows Service that uses ODP.NET, Oracle Database, a Custom Event Log, and Local Service</title><content type="html">&lt;p&gt;The steps necessary to create a Windows Service that accesses Oracle Database via ODP.NET and uses the &amp;quot;NT AUTHORITY\LOCAL SERVICE&amp;quot; low-privileged operating system account are not substantially different from the steps necessary to create a service that does not access Oracle Database. As such, the steps below are substantially similar to the steps in the &amp;quot;Walkthrough: Creating a Windows Service Application in the Component Designer&amp;quot; topic available in the Visual Studio Programmer's Guide for the .NET Framework. You may wish to review this walkthrough in addition to the steps I provide below.&lt;/p&gt;  &lt;p&gt;My goal is to provide the steps necessary to create a (very) simplistic Windows Service that uses the &amp;quot;NT AUTHORITY\LOCAL SERVICE&amp;quot; account to &amp;quot;talk&amp;quot; to Oracle Database. This is by no means an all-encompassing treatment of the topic of using a Windows Service in conjunction with ODP.NET, etc. However, it should provide the minimum amount of information to get started down this path.&lt;/p&gt;  &lt;p&gt;So, without further ado, let's get started...&lt;/p&gt;  &lt;h3&gt;The Setup&lt;/h3&gt;  &lt;p&gt;Because this solution needs an installer, I am not using an Express Edition of Visual Studio. I'm using Visual Studio 2005 with ODP.NET 11.1.6.20 on a Windows XP Professional machine. This machine will also serve as the deployment target for the installer and is hosting an Oracle 11g Release 1 database.&lt;/p&gt;  &lt;h3&gt;Create the Visual Studio Project&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Select File -&amp;gt; New -&amp;gt; Project... from the main menu.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; In the New Project dialog expand the Visual C# node under Project types, click the Windows option, select Windows Service in the Templates list, enter OraWinService as the Name, and select an appropriate location (or simply accept the suggested location). The New Project dialog should resemble the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/oradim.maw/SIkTFRFks-I/AAAAAAAAAGg/E8SWz4RHLC4/s1600-h/OraWinService013.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="167" alt="OraWinService01" src="http://lh6.ggpht.com/oradim.maw/SIkTFpuG23I/AAAAAAAAAGk/qUjz4YJUgqs/OraWinService01_thumb1.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3.&amp;#160; Click OK to create the project.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Add a Reference to the ODP.NET Assembly&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Select Project -&amp;gt; Add Reference... from the main menu.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; In the Add Reference dialog, scroll down and select Oracle.DataAccess under the Component Name. The dialog should look similar to the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/oradim.maw/SIkTF8TXovI/AAAAAAAAAGo/oKKhVY1IzRw/s1600-h/OraWinService026.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="197" alt="OraWinService02" src="http://lh3.ggpht.com/oradim.maw/SIkTGENJK9I/AAAAAAAAAGs/xrKE6lqCqQs/OraWinService02_thumb2.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3. Click OK to add the reference.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Set the Service Properties&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; The Service1.cs file should be displayed in the design view. If it is not, right-click the Service1.cs file in the Solution Explorer and select View Designer.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; Ensure the Service1.cs file is selected in the designer by clicking anywhere on the surface &lt;em&gt;except&lt;/em&gt; for on the hyperlinks.&lt;/p&gt;  &lt;p&gt;3.&amp;#160; In the Properties window for Service1.cs, enter OraWinSvcDemo for the (Name) property. Also enter OraWinSvcDemo for the ServiceName property. Set the CanPauseAndContinue property to True. The AutoLog property should also be set to True, which is the default. When complete, the Properties window should resemble:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/oradim.maw/SIkTGcEWmBI/AAAAAAAAAGw/oi1JFyUjqhk/s1600-h/OraWinService033.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="OraWinService03" src="http://lh5.ggpht.com/oradim.maw/SIkTGnM1pJI/AAAAAAAAAG0/RqfDgg8sXH8/OraWinService03_thumb1.png?imgmax=800" width="229" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Edit the Main Method&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Double-click the Program.cs file in the Solution Explorer to open it in the editor.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; Replace the auto-created Main method with the following code:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;static void Main() {      &lt;br /&gt;&amp;#160; System.ServiceProcess.ServiceBase[] ServicesToRun;       &lt;br /&gt;&amp;#160; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new OraWinSvcDemo() };       &lt;br /&gt;&amp;#160; System.ServiceProcess.ServiceBase.Run(ServicesToRun);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;3.&amp;#160; Select File -&amp;gt; Save All from the main menu and then select File -&amp;gt; Close from the main menu to close the Program.cs file.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Add an EventLog Component&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; With the Service1.cs file displayed in the design view, expand the Components node in the Toolbox and drag and drop an EventLog component onto the design surface. This will create an instance of the EventLog component named eventLog1.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; If eventLog1 is not selected, left-click it to select. In the Properties window enter OraWinSvcLog for the Log property and enter OraWinSvcSource for the Source property. The Properties window should now look as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/oradim.maw/SIkTG2HZEwI/AAAAAAAAAG4/O7RXfmzWB74/s1600-h/OraWinService04%5B3%5D.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="OraWinService04" src="http://lh4.ggpht.com/oradim.maw/SIkTHKoenBI/AAAAAAAAAG8/FT4rme0vQpM/OraWinService04_thumb%5B1%5D.png?imgmax=800" width="229" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Define the Service Methods&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Right-click the Service1.cs file in the Solution Explorer and select View Code from the context menu to open the file in the editor.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; Add the following three lines to the end of the &amp;quot;list of using statements&amp;quot;. A timer will be used to periodically trigger an event to write information to the Event Log. The other two lines are boilerplate inclusions for the ODP.NET namespaces.&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using System.Timers;      &lt;br /&gt;using Oracle.DataAccess.Client;       &lt;br /&gt;using Oracle.DataAccess.Types;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;3.&amp;#160; At the top of the class definition (but outside of any method definitions) add the following (be sure to adjust the Data Source in the connection string as appropriate for your environment). The user will be created later:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;string constr = &amp;quot;User Id=/; Data Source=orademo; Enlist=false&amp;quot;;      &lt;br /&gt;OracleConnection con = null;       &lt;br /&gt;Timer timer1 = null;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;At this time the entire Service1.cs file should contain the following:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using System;      &lt;br /&gt;using System.Collections.Generic;       &lt;br /&gt;using System.ComponentModel;       &lt;br /&gt;using System.Data;       &lt;br /&gt;using System.Diagnostics;       &lt;br /&gt;using System.ServiceProcess;       &lt;br /&gt;using System.Text;       &lt;br /&gt;using System.Timers;&lt;/font&gt;&lt;font face="Courier New"&gt;      &lt;br /&gt;using Oracle.DataAccess.Client;       &lt;br /&gt;using Oracle.DataAccess.Types; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;namespace OraWinService {      &lt;br /&gt;&amp;#160; public partial class OraWinSvcDemo : ServiceBase {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string constr = &amp;quot;User Id=/; Data Source=orademo; Enlist=false&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; OracleConnection con = null;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Timer timer1 = null; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; public OraWinSvcDemo() {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeComponent();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; protected override void OnStart(string[] args) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // TODO: Add code here to start your service.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; protected override void OnStop() {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // TODO: Add code here to perform any tear-down necessary to stop your service.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;4.&amp;#160; Change the constructor to the following to create the timer and set the handler function for the timer event:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;public OraWinSvcDemo() {      &lt;br /&gt;&amp;#160; InitializeComponent(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; timer1 = new Timer(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; timer1.Elapsed += new ElapsedEventHandler(OnTimer);      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;5.&amp;#160; Add the OnTimer method below the constructor to handle the timer event:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;private void OnTimer(object source, ElapsedEventArgs e) {      &lt;br /&gt;&amp;#160; if (con != null) {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if (con.State == ConnectionState.Open) {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleCommand cmd = con.CreateCommand();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;select user, sysdate from dual&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleDataReader dr = cmd.ExecuteReader();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; while (dr.Read()) {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; eventLog1.WriteEntry(String.Format(&amp;quot;User: {0}, Date: {1}&amp;quot;, dr[0].ToString(), dr[1].ToString()));       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dr.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Dispose();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Close();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;6.&amp;#160; Replace the generated OnStart method with the following which establishes a connection to the database and sets the timer properties (interval of 3 seconds and enables the timer):&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;protected override void OnStart(string[] args) {      &lt;br /&gt;&amp;#160; eventLog1.WriteEntry(&amp;quot;In OnStart&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; con = new OracleConnection(constr); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; try {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con.Open();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; eventLog1.WriteEntry(&amp;quot;Successfully connected to Oracle!&amp;quot;);       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;&amp;#160; catch (OracleException ex) {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; eventLog1.WriteEntry(&amp;quot;OracleException: &amp;quot; + ex.Message);       &lt;br /&gt;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; timer1.Interval = 3000;      &lt;br /&gt;&amp;#160; timer1.Enabled = true;       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;7.&amp;#160; Replace the generated OnStop method with the following code:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;protected override void OnStop() {      &lt;br /&gt;&amp;#160; eventLog1.WriteEntry(&amp;quot;In OnStop&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; timer1.Enabled = false; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; if (con != null) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con.Dispose();       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;8.&amp;#160; Add a handler for the OnPause event for the service below the OnStop method:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;protected override void OnPause() {      &lt;br /&gt;&amp;#160; eventLog1.WriteEntry(&amp;quot;In OnPause.&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; timer1.Enabled = false;      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;9.&amp;#160; Add a handler for the OnContinue event for the service below the OnPause method:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;protected override void OnContinue() {      &lt;br /&gt;&amp;#160; eventLog1.WriteEntry(&amp;quot;In OnContinue.&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; timer1.Enabled = true;      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;10.&amp;#160; Add a handler for the shutdown event below the handler for the OnContinue event:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;protected override void OnShutdown() {      &lt;br /&gt;&amp;#160; eventLog1.WriteEntry(&amp;quot;In OnShutdown&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; timer1.Enabled = false; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; if (con != null) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con.Dispose();       &lt;br /&gt;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;11.&amp;#160; Select File -&amp;gt; Save All from the main menu to save all work and File -&amp;gt; Close to close the Service1.cs file in the editor.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Create Installers for the Components&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Service1.cs should in the design view mode within the editor. If it is not, right-click it in the Solution Explorer and select View Designer from the context menu.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; Create an installer by right-clicking on the design surface and selecting Add Installer from the context menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/oradim.maw/SIkTHCU-7qI/AAAAAAAAAHA/9mSl32dOPCE/s1600-h/OraWinService062.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="194" alt="OraWinService06" src="http://lh4.ggpht.com/oradim.maw/SIkTHb3R2lI/AAAAAAAAAHE/OLNZETOfuPA/OraWinService06_thumb.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3.&amp;#160; After clicking Add Installer, ProjectInstaller.cs will be created and opened in the editor. Click the Service1.cs [Design] tab to switch back to Service1.cs in the editor. Add an installer for the eventLog1 component by right-clicking it and selecting Add Installer from the context menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/oradim.maw/SIkTHokIyzI/AAAAAAAAAHI/RuxE2pL3cJU/s1600-h/OraWinService052.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="OraWinService05" src="http://lh5.ggpht.com/oradim.maw/SIkTH8L4CpI/AAAAAAAAAHM/39IE21_Kx8c/OraWinService05_thumb.png?imgmax=800" width="234" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;4.&amp;#160; After adding the eventLog1 installer, left-click the serviceProcessInstaller1 component to select it. Next select LocalService from the drop-down list:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/oradim.maw/SIkTH79zC9I/AAAAAAAAAHQ/Aod1VqNKmBY/s1600-h/OraWinService072.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="OraWinService07" src="http://lh4.ggpht.com/oradim.maw/SIkTIU3ViYI/AAAAAAAAAHU/tqAhqXsTwL0/OraWinService07_thumb.png?imgmax=800" width="229" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;5.&amp;#160; Select File -&amp;gt; Save All from the main menu to save all files.&lt;/p&gt;  &lt;p&gt;6.&amp;#160; Select Build -&amp;gt; Build OraWinService from the main menu to build the project, then select File -&amp;gt; Close twice to close the ProjectInstaller.cs and Service1.cs files.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Create a Setup Project for the Service&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Select File -&amp;gt; Add -&amp;gt; New Project... from the main menu, in the Project types pane expand the Other Project Types node, select Setup and Deployment, select Setup Project in the Templates list, enter OraWinServiceSetup for the Name, and select an appropriate location (or accept the default supplied value). The Add New Project dialog should look as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/oradim.maw/SIkTIr2XJ9I/AAAAAAAAAHY/Fct1P3-GpaA/s1600-h/OraWinService082.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="158" alt="OraWinService08" src="http://lh6.ggpht.com/oradim.maw/SIkTJFaY9BI/AAAAAAAAAHc/yTzIO5a1tY4/OraWinService08_thumb.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;2.&amp;#160; Click OK to add the setup project to the solution.&lt;/p&gt;  &lt;p&gt;3.&amp;#160; In Solution Explorer, right-click OraWinServiceSetup then select Add -&amp;gt; Project Output... from the context menu. The Add Project Output Group dialog will be displayed:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/oradim.maw/SIkTJUVov2I/AAAAAAAAAHg/xyf6x8P5yRc/s1600-h/OraWinService092.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="OraWinService09" src="http://lh5.ggpht.com/oradim.maw/SIkTJrIlFVI/AAAAAAAAAHk/88YObLTM-PA/OraWinService09_thumb.png?imgmax=800" width="209" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;4.&amp;#160; Ensure Primary Output is selected and click OK.&lt;/p&gt;  &lt;p&gt;5.&amp;#160; In Solution Explorer, right-click OraWinServiceSetup then select View -&amp;gt; Custom Actions from the context menu to open the custom actions in the editor.&lt;/p&gt;  &lt;p&gt;6.&amp;#160; In the Custom Action editor, right-click Custom Actions and select Add Custom Action... from the context menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/oradim.maw/SIkTJmNqwAI/AAAAAAAAAHo/BOG9Vqknma0/s1600-h/OraWinService102.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="112" alt="OraWinService10" src="http://lh3.ggpht.com/oradim.maw/SIkTJ8mqDEI/AAAAAAAAAHs/Po1S3WVhXZk/OraWinService10_thumb.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;7.&amp;#160; In the Select Item in Project dialog, double-click the Application Folder item, then select Primary output from OraWinService (Active), and click OK to add the output to each of the Install, Commit, Rollback, and Uninstall nodes:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/oradim.maw/SIkTKFq1AWI/AAAAAAAAAHw/bScTjKEntb0/s1600-h/OraWinService112.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="175" alt="OraWinService11" src="http://lh6.ggpht.com/oradim.maw/SIkTKDz08hI/AAAAAAAAAH0/aUl8hgGt-RE/OraWinService11_thumb.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;8.&amp;#160; Select File -&amp;gt; Save All from the main menu and then File -&amp;gt; Close for each opened file in the editor.&lt;/p&gt;  &lt;p&gt;9.&amp;#160; Build the setup program by right-clicking OraWinServiceSetup in Solution Explorer and selecting Build from the context menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/oradim.maw/SIkTKTphMYI/AAAAAAAAAH4/IfatvxUDHuU/s1600-h/OraWinService122.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="OraWinService12" src="http://lh4.ggpht.com/oradim.maw/SIkTKjHc64I/AAAAAAAAAH8/WWeMHvWzYew/OraWinService12_thumb.png?imgmax=800" width="97" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Install the Windows Service&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Using Windows Explorer navigate to the directory where the setup project was built. For example, on my system this is in C:\My Projects\Test\C#\OraWinServiceSetup\Debug directory.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; Install the service by right-clicking the OraWinServiceSetup.msi file and selecting Install from the context menu. Step through the installation wizard to complete the installation.&lt;/p&gt;  &lt;h3&gt;Create the Database User&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Connect to the database that the service will use as a DBA user and determine the value of the os_authent_prefix parameter:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SQL&amp;gt; show parameter os_authent_prefix &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;NAME&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TYPE&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; VALUE      &lt;br /&gt;----------------- ----------- -----       &lt;br /&gt;os_authent_prefix string&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;2. As you can see here I do not have a value for this parameter; therefore, when I create the user I do not use a prefix:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SQL&amp;gt; create user &amp;quot;NT AUTHORITY\LOCAL SERVICE&amp;quot; identified externally; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;User created. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SQL&amp;gt; grant create session to &amp;quot;NT AUTHORITY\LOCAL SERVICE&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Grant succeeded.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;3.&amp;#160; For more information on creating an Operating System authenticated user, see my earlier post on &lt;a title="Configuring Windows Authentication" href="http://oradim.blogspot.com/2007/11/configuring-windows-authentication.html" target="_blank"&gt;Configuring Windows Authentication&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Running the Service and Viewing Results&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;1.&amp;#160; Open the Services management console by clicking Start -&amp;gt; Administrative Tools -&amp;gt; Services. You can also right-click the My Computer icon on the desktop and select Manage from the context menu.&lt;/p&gt;  &lt;p&gt;2.&amp;#160; Locate the OraWinSvcDemo service in the list of services and click the start button:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/oradim.maw/SIkTK6v5m0I/AAAAAAAAAIA/gh-m7zPUYW4/s1600-h/OraWinService13%5B2%5D.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="171" alt="OraWinService13" src="http://lh6.ggpht.com/oradim.maw/SIkTLCqkkcI/AAAAAAAAAIE/j3pwSuGQiA8/OraWinService13_thumb.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3.&amp;#160; Open the Event Viewer by clicking Start -&amp;gt; Administrative Tools -&amp;gt; Event viewer. Or right-click the My Computer icon on the desktop and select Manage from the context menu (if you have not already done so).&lt;/p&gt;  &lt;p&gt;4.&amp;#160; In the Event Viewer, select OraWinSvcLog by left-clicking it. As the service writes entries to the log every 3 seconds while it is executing, you should see several entries after a 10 seconds or so:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/oradim.maw/SIkTLdoqDcI/AAAAAAAAAII/7C2C1xiYakQ/s1600-h/OraWinService14%5B2%5D.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="OraWinService14" src="http://lh5.ggpht.com/oradim.maw/SIkTLpSNPpI/AAAAAAAAAIM/ZXC9qZ4TCmU/OraWinService14_thumb.png?imgmax=800" width="220" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;5.&amp;#160; Experiment with the different service states (paused, resume, restart, etc) and verify the entries in the Event Viewer.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-5170977328607724173?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/5170977328607724173/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/07/creating-windows-service-that-uses.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/5170977328607724173?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/5170977328607724173?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/HUm_9TEB0n8/creating-windows-service-that-uses.html" title="Creating a Windows Service that uses ODP.NET, Oracle Database, a Custom Event Log, and Local Service" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/07/creating-windows-service-that-uses.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcCQHc8cCp7ImA9WxdXFkU.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-3708626502653918348</id><published>2008-06-28T17:21:00.001-04:00</published><updated>2008-06-28T17:21:01.978-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-28T17:21:01.978-04:00</app:edited><title>Oracle OpenWorld 2008 San Francisco</title><content type="html">&lt;p&gt;&lt;/p&gt;  &lt;p&gt;It's hard to believe, but &lt;a href="http://www.oracle.com/openworld/2008/index.html" target="_blank"&gt;Oracle OpenWorld 2008&lt;/a&gt; in San Francisco is coming round fast! I will be attending this year and here's my Oracle Mix profile link (free account required):&lt;/p&gt;  &lt;p&gt;&lt;a title="Mark Williams Oracle Mix Profile" href="https://mix.oracle.com/user_profiles/25732-mark-williams" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="74" alt="oow_mix_2008" src="http://lh5.ggpht.com/oradim.maw/SGarPQxRogI/AAAAAAAAAGc/oIe1IeuXS3k/oow_mix_2008%5B3%5D.png?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I've been really busy with the day job though I plan to have some more technical content in the near future! I've a couple of ideas swimming around that may be interesting as they're based on real questions.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-3708626502653918348?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/3708626502653918348/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/06/oracle-openworld-2008-san-francisco.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3708626502653918348?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3708626502653918348?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/ZK2Y1tsuVYM/oracle-openworld-2008-san-francisco.html" title="Oracle OpenWorld 2008 San Francisco" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/06/oracle-openworld-2008-san-francisco.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIEQXY6fip7ImA9WxdSGU4.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-3958603542091331290</id><published>2008-05-27T19:21:00.001-04:00</published><updated>2008-05-27T19:21:40.816-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-27T19:21:40.816-04:00</app:edited><title>Recommended by Joe</title><content type="html">&lt;p&gt;A friend of mine at Oracle (that is to say Greg is still at Oracle whilst I am not) pointed out to me that Microsoft's Joe Stagner has Pro .NET Oracle Programming as a recommended book on the &lt;a href="http://forums.asp.net/57.aspx" target="_blank"&gt;Oracle - ASP.NET forum&lt;/a&gt;. Currently the recommended books list looks like this (subject to change naturally):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/oradim.maw/SDyXgP__LkI/AAAAAAAAAEA/BAggVyxae3Q/s1600-h/joe_stagner_recommends_me%5B2%5D.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="joe_stagner_recommends_me" src="http://lh6.ggpht.com/oradim.maw/SDyXgv__LlI/AAAAAAAAAEI/hn2HLLqqkSU/joe_stagner_recommends_me_thumb.png?imgmax=800" width="165" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;That got me to thinking a bit. It has been just over 4 years since I started writing that book. (I started the first chapter in March 2004). Certainly a lot has changed since then with several releases of the Oracle Data Provider for .NET, Oracle Database, Visual Studio, the Oracle Developer Tools for Visual Studio .NET, etc. I was just at one of the major booksellers here locally over the weekend and the &amp;quot;computer section&amp;quot; has dwindled immensely. I wonder if it would be worthwhile to update the book? There are several things I would want to change to be sure, but would it be worth it? Do people get their technical information from OTN and MSDN mostly now?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-3958603542091331290?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/3958603542091331290/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/05/recommended-by-joe.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3958603542091331290?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3958603542091331290?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/lO4yprGzNkw/recommended-by-joe.html" title="Recommended by Joe" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/05/recommended-by-joe.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8GRXY-fyp7ImA9WxdTE0s.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-9169439718917579640</id><published>2008-05-09T17:17:00.001-04:00</published><updated>2008-05-09T17:17:04.857-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-09T17:17:04.857-04:00</app:edited><title>ODTUG Kaleidoscope 2008</title><content type="html">&lt;p&gt;It's ODTUG time again! It is a great opportunity to see lots of Oracle folks like Tom Kyte, Sue Harper, Joel Kallman, David Peake, Carl Backstrom, as well as a ton of other great people!&lt;/p&gt;  &lt;p&gt;June 15-19, 2008   &lt;br /&gt;New Orleans, Louisiana    &lt;br /&gt;    &lt;br /&gt;ODTUG Kaleidoscope 2008 &amp;#8211; the annual conference of the Oracle Development Tools User Group, will be held this June 15-19, 2008 in New Orleans, Louisiana. Packed with technical sessions, four individual keynotes, three symposiums, a dedicated Hyperion track crafted by the masters, and a special gathering of Oracle Ace Directors, ODTUG Kaleidoscope offers the most comprehensive in-depth technical conference available for Oracle professionals. Unlike other conferences in this category, ODTUG Kaleidoscope strives to provide real world knowledge by real world technologists and provide a conference experience that will truly help Oracle developers take their role to the next level. For additional information and a complete agenda, visit &lt;a href="http://www.odtugkaleidoscope.com/" target="_blank"&gt;www.odtugkaleidoscope.com&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-9169439718917579640?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/9169439718917579640/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/05/odtug-kaleidoscope-2008.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/9169439718917579640?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/9169439718917579640?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/rmP5c3Z7jQE/odtug-kaleidoscope-2008.html" title="ODTUG Kaleidoscope 2008" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/05/odtug-kaleidoscope-2008.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAHQX86cSp7ImA9WxZaGE8.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-832120250809817570</id><published>2008-05-03T11:15:00.001-04:00</published><updated>2008-05-03T11:15:30.119-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-03T11:15:30.119-04:00</app:edited><title>Using Delegates to make a Synchronous Database Call Asynchronously</title><content type="html">&lt;p&gt;There are times when a tight coupling exists between user interaction with an application and database calls. That is, a user initiates an action that requires a database call, the database call executes, the call to the database returns, the user responds, and the cycle continues in fairly rapid succession. However, there are also times when a user may initiate an action that requires a lengthy database call. Of course, lengthy is a relative term and would be defined within your own environment. What is lengthy to one may not be lengthy to another. Something of a judgement call on that one.&lt;/p&gt;  &lt;p&gt;If a lengthy database call is initiated from an application you may desire the capability to continue to do other work within that application while the database call executes. However, as current production versions of the Oracle Data Provider for .NET (ODP.NET) do not offer Begin&lt;em&gt;XXX&lt;/em&gt; and End&lt;em&gt;XXX&lt;/em&gt; methods (such as BeginExecuteNonQuery() for example), you may think offering this functionality in your ODP.NET application is not possible or is difficult. Again, depending on your application specifics, offering such asynchronous behavior may give your application better responsiveness and increase the end-user experience positively.&lt;/p&gt;  &lt;p&gt;One method of achieving this goal (calling a synchronous method asynchronously) is by using delegates. If you are not familiar with delegates, I suggest reviewing the &lt;a href="http://msdn.microsoft.com/en-us/library/ms173171(VS.80).aspx" target="_blank"&gt;Delegates&lt;/a&gt; topic in the online version of the C# Programming Guide on Microsoft's MSDN site. In addition to the standard reference information, there is also a tutorial (again located on MSDN) which can be found &lt;a href="http://msdn.microsoft.com/en-us/library/aa288459(VS.71).aspx" target="_blank"&gt;here&lt;/a&gt;. Of course these links are subject to change in the future.&lt;/p&gt;  &lt;p&gt;In order to implement this technique you will need two methods (other than the Main method of course). One method will perform the synchronous database call and the other method will be invoked when that call is complete. A delegate is created for the method that performs the database call. This is the key to the technique. By creating a delegate for this synchronous method it becomes possible to invoke it asynchronously via the BeginInvoke() method exposed by the delegate. The delegate keyword actually causes the compiler to expand the declaration into a class which contains a BeginInvoke() method (among others).&lt;/p&gt;  &lt;p&gt;The sample code below is a simple implementation of this technique using a console application. In this application a &amp;quot;do nothing&amp;quot; call to the database occurs. This call does nothing more than sleep inside the database for a specified period of time. As noted in the source code comments, the database user must have the &amp;quot;execute&amp;quot; privilege on the dbms_lock PL/SQL package for the code to work. Of course a real application would not normally connect to the database only to sleep for a period of time and return; however, this is a sufficient method for illustrating that the call is asynchronous in relation to the main thread.&lt;/p&gt;  &lt;p&gt;The basic flow is as follows:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create the delegate&lt;/li&gt;    &lt;li&gt;Invoke the delegate to execute asynchronously from the main thread&lt;/li&gt;    &lt;li&gt;Continue processing in the main thread while the database call is in progress&lt;/li&gt;    &lt;li&gt;When database call is complete, invoke the OnCallComplete() method&lt;/li&gt;    &lt;li&gt;Work in the main thread continues for a short period of time&lt;/li&gt;    &lt;li&gt;Along the way prompt information is displayed and a final prompt is provided&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;It is necessary to cause the main thread to have a longer duration than the thread performing the database call because if the main thread ended before the database call thread the entire console application would terminate.&lt;/p&gt;  &lt;p&gt;When the application is executed you should see output similar to the following:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Asynchronous call in progress.     &lt;br /&gt;&amp;#160; Will sleep in database for 10 seconds.      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160; Enter LongDatabaseCall      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160; Exit LongDatabaseCall      &lt;br /&gt;&amp;#160; Enter OnCallComplete      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Perform post-database call actions...      &lt;br /&gt;&amp;#160; Exit OnCallComplete      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...      &lt;br /&gt;Press ENTER to continue...&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;As you can see, the basic flow above is represented here and work in the main thread continues after the LongDatabaseCall method has been invoked via the delegate.&lt;/p&gt;  &lt;p&gt;Here's the (hopefully) well-commented code to produce the above:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using System;     &lt;br /&gt;using System.Threading;      &lt;br /&gt;using System.Data;      &lt;br /&gt;using Oracle.DataAccess.Client;      &lt;br /&gt;using Oracle.DataAccess.Types; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;namespace AsynchronousDemo     &lt;br /&gt;{      &lt;br /&gt;&amp;#160; class Program      &lt;br /&gt;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // change as necessary for your environment      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // the user must have execute privilege on dbms_lock      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; const string constr = &amp;quot;User Id=hr;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Password=hr;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Data Source=orademo;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Enlist=false&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // the delegate for the function that makes the db call     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; internal delegate void LongCallDelegate(int sleepSeconds); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; static void Main(string[] args)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // the amount of time the call to the database will sleep      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int sleepSeconds = 10; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // write marker text to console to indicate beginning of process     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Asynchronous call in progress.&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;&amp;#160; Will sleep in database for {0} seconds.&amp;quot;, sleepSeconds.ToString()); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // used to call the function     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LongCallDelegate ldc = new LongCallDelegate(LongDatabaseCall); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // call BeginInvoke to make call asynchronous     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // the method to invoke when the call has completed is passed      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // as the second parameter      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ldc.BeginInvoke(sleepSeconds, OnCallComplete, ldc); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // cause main thread to &amp;quot;pause&amp;quot; while the database call is in progress     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // add an arbitrary number (5) to the sleepSeconds to help show that      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // the database call is &amp;quot;independent&amp;quot; of the main thread      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; for (int i = 1; i &amp;lt; sleepSeconds + 5; i++)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;&amp;#160;&amp;#160;&amp;#160; Doing work in Main thread...&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Thread.Sleep(1000);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // prevent console from automatically closing as when run from VS in debug mode     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Press ENTER to continue...&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.ReadLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; static void LongDatabaseCall(int sleepSeconds)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // this is the function that makes the database call      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // it will be called from the delegate to make the call      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // asynchronous in relation to the main thread &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // marker text     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;&amp;#160; Enter LongDatabaseCall&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create and open connection to database     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleConnection con = new OracleConnection(constr);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Open(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create command object     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // will call dbms_lock to sleep for x seconds in database      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleCommand cmd = con.CreateCommand();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;begin dbms_lock.sleep(:1); end;&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // parameter for the sleep duration     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleParameter p_sleepSeconds = new OracleParameter(&amp;quot;1&amp;quot;,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleDbType.Decimal,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sleepSeconds,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ParameterDirection.Input); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // add parameter to the collection for the command object     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(p_sleepSeconds); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // make the database call     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // clean up     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; p_sleepSeconds.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Dispose(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // marker text     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;&amp;#160; Exit LongDatabaseCall&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; static void OnCallComplete(IAsyncResult ar)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // marker text      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;&amp;#160; Enter OnCallComplete&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // get the delegate from the IAsyncResult object     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LongCallDelegate ldc = (LongCallDelegate)ar.AsyncState; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Must call EndInvoke to pair with BeginInvoke     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ldc.EndInvoke(ar); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // marker text     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;&amp;#160;&amp;#160;&amp;#160; Perform post-database call actions...&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;&amp;#160; Exit OnCallComplete&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-832120250809817570?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/832120250809817570/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/05/using-delegates-to-make-synchronous.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/832120250809817570?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/832120250809817570?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/kCDuDpjgo64/using-delegates-to-make-synchronous.html" title="Using Delegates to make a Synchronous Database Call Asynchronously" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/05/using-delegates-to-make-synchronous.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cGRHo6cSp7ImA9WxZUFkQ.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-7804412035724584331</id><published>2008-04-08T19:54:00.001-04:00</published><updated>2008-04-08T19:57:05.419-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-08T19:57:05.419-04:00</app:edited><title>Generating Test Data</title><content type="html">&lt;p&gt;I'm an advocate of testing things - it can be a great way to discover different behaviors and learn how things work (or perhaps why they didn't work the way you thought they might!). When it comes to testing database applications, having some test data is certainly helpful. Ideally, I like to have a fully-loaded production database from which to draw this data into a test environment. Sometimes, however, this is not possible. In cases like these I use the &amp;quot;trick&amp;quot; described below to create my own test data.&lt;/p&gt;  &lt;p&gt;When I need to generate test data I frequently call upon a seemingly little-known PL/SQL Package supplied with Oracle Database called &amp;quot;&lt;a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_random.htm#sthref6707" target="_blank"&gt;dbms_random&lt;/a&gt;&amp;quot;. As you may guess this package can be used to generated random data. Rather than explain the package details (they are short and you can read them using the link), I'll just present a quick way to generate some data using SQL*Plus and the dbms_random package.&lt;/p&gt;  &lt;p&gt;First, I'll need a table:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;create table test_data      &lt;br /&gt;(       &lt;br /&gt;&amp;#160; id number,       &lt;br /&gt;&amp;#160; first_name varchar2(16),       &lt;br /&gt;&amp;#160; last_name varchar2(24),       &lt;br /&gt;&amp;#160; amount number(6,2),       &lt;br /&gt;&amp;#160; purchase_date date       &lt;br /&gt;);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;As you can see, this table is nothing to write home about, but it does mirror what a real-world table would look like in a lot of cases.&lt;/p&gt;  &lt;p&gt;When I am creating test data I generally prefer the data to be reproducible. That is, if I execute the process more than once I like to get the same data each time. To accomplish this with the dbms_random package I call the &amp;quot;seed&amp;quot; procedure and provide an initial seed value:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;exec dbms_random.seed(42);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Let's say I wanted to populate this table with 10,000 rows of data. I use the following to do this:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;insert into test_data      &lt;br /&gt;select       &lt;br /&gt;&amp;#160; rownum,       &lt;br /&gt;&amp;#160; initcap(dbms_random.string('l',dbms_random.value(2,16))),       &lt;br /&gt;&amp;#160; initcap(dbms_random.string('l',dbms_random.value(2,24))),       &lt;br /&gt;&amp;#160; round(dbms_random.value(1,1000),2),       &lt;br /&gt;&amp;#160; to_date('01-JAN-2008', 'DD-MON-YYYY') + dbms_random.value(-100,100)       &lt;br /&gt;from       &lt;br /&gt;&amp;#160; (select level from dual connect by level &amp;lt;= 10000);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Starting at the bottom of the SQL text is a neat trick using &amp;quot;dual&amp;quot; and &amp;quot;connect by&amp;quot; to essentially create an &amp;quot;unlimited dual&amp;quot; for generating lots of rows. This trick was (I believe) originally put forth by Mikito Harakiri and I discovered it via an &lt;a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:34808326503816#34823249753962" target="_blank"&gt;Ask Tom thread&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The remainder of the text is fairly straight-forward in its use of the dbms_random package. I use the &amp;quot;string&amp;quot; function to generate a random, lowercase value (which is subsequently passed to &amp;quot;initcap&amp;quot; to capitalize the first character of each string), the &amp;quot;value&amp;quot; function is used to create a random numeric value (which is passed to &amp;quot;round&amp;quot; to make it look like a purchase amount), and then I use a fixed-date to which I add (possibly a negative value) to create a set of valid dates within a range.&lt;/p&gt;  &lt;p&gt;The first 10 rows of this data when selected from the table look like:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;ID FIRST_NAME&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LAST_NAME&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AMOUNT PURCHASE_DATE      &lt;br /&gt;--- ---------------- ------------------------ ---------- --------------------       &lt;br /&gt;&amp;#160; 1 Oqq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Mxsazbwyx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 521.33 22-MAR-2008 16:49:40       &lt;br /&gt;&amp;#160; 2 Jjgqrywtxbdn&amp;#160;&amp;#160;&amp;#160;&amp;#160; Fwwbzshhkbqzb&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 921.47 04-OCT-2007 09:10:00       &lt;br /&gt;&amp;#160; 3 Zxflhufls&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Mstwydowbaogeyyjiles&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 172.34 20-MAR-2008 10:22:05       &lt;br /&gt;&amp;#160; 4 Zjjxtyysitsog&amp;#160;&amp;#160;&amp;#160; Zxrzqeflxgo&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 882.16 26-DEC-2007 18:56:44       &lt;br /&gt;&amp;#160; 5 Kjmuvbrqx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Hfu&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 742.61 16-OCT-2007 14:35:27       &lt;br /&gt;&amp;#160; 6 Oywaibiyp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Angvlehlmeujfdlhdmtt&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 664.5 29-FEB-2008 12:50:40       &lt;br /&gt;&amp;#160; 7 Uhwyvla&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Nhbwcv&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 168.99 27-DEC-2007 22:29:59       &lt;br /&gt;&amp;#160; 8 Kpdiqafanbvzt&amp;#160;&amp;#160;&amp;#160; Phjeqwelyugrmahybocwbhvp&amp;#160;&amp;#160;&amp;#160;&amp;#160; 813.81 01-MAR-2008 09:15:59       &lt;br /&gt;&amp;#160; 9 Tvezuvrgnzzqkpq&amp;#160; Pjyygoqx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 880.09 21-NOV-2007 00:42:07       &lt;br /&gt; 10 Olchylbeft&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Nflaxjqfkmkgt&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 847.71 07-DEC-2007 16:53:23 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;10 rows selected.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Can this technique always be used? No, probably not. For example, the names are not exactly what you might call &amp;quot;proper&amp;quot; names. However, I do find that this technique can be useful when I need to create some data to perform some testing with. Perhaps it will be helpful to you too if you experiment with it and find the right combination of values to use in your tests.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-7804412035724584331?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/7804412035724584331/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/04/generating-test-data.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/7804412035724584331?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/7804412035724584331?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/bqV0APweLsE/generating-test-data.html" title="Generating Test Data" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/04/generating-test-data.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0ENRXY4fCp7ImA9WxZUFEQ.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-362447476360331620</id><published>2008-04-06T12:34:00.001-04:00</published><updated>2008-04-06T12:34:54.834-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-06T12:34:54.834-04:00</app:edited><title>Applications and Data == Importance Envy?</title><content type="html">&lt;p&gt;I was recently reading an interesting posting (and comments) over on Doug Burns' Blog:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://oracledoug.com/serendipity/index.php?/archives/1394-Theres-Hope-for-us-all.html" href="http://oracledoug.com/serendipity/index.php?/archives/1394-Theres-Hope-for-us-all.html"&gt;http://oracledoug.com/serendipity/index.php?/archives/1394-Theres-Hope-for-us-all.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Doug's blog is a great resource and I encourage you to check it out if you have a few spare minutes.&lt;/p&gt;  &lt;p&gt;I found this interesting because the &amp;quot;debate&amp;quot; around which is more important -- the application or the data -- raises its head every now and then. Now, my being a DBA in my &amp;quot;day job&amp;quot; may automatically bias me in this context; however, I was a developer before I was a DBA. This, of course, does not mean I am bias-free, but I do hope that I am not so closed-minded that I may see both sides of a discussion.&lt;/p&gt;  &lt;p&gt;When I hear this question (which is more important? the application? or the data? OK, so that is three questions, but you understand.) I immediately think of a question I was posed long ago in school - which is more important, the heart or the blood? Of course there is not a perfect correlation between biology and applications and data, but I think that is not an unreasonable analogy. While not exactly easy, it is possible to find other mechanisms to transport the blood, but it is not so easy to replace the blood itself.&lt;/p&gt;  &lt;p&gt;Clearly both applications and data are important. However, rather than necessarily declare one to be more important than the other, my inclination is to view them in terms of life span. Often I hear something along the lines of: &lt;em&gt;An&lt;/em&gt; application is used to access &lt;em&gt;the&lt;/em&gt; data. To me this implies that there may be more than one application or a series of applications over time whereas the data itself is not really viewed as having multiple incarnations. If I may borrow a quote from &lt;em&gt;The Kinks&lt;/em&gt;: &amp;quot;Rocks bands will come and rock bands will go, but Rock 'n Roll will go on forever!&amp;quot; (From a live performance of &amp;quot;All Day and All of the Night&amp;quot; as I recall).&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-362447476360331620?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/362447476360331620/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/04/applications-and-data-importance-envy.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/362447476360331620?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/362447476360331620?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/lsNkIHDsVRQ/applications-and-data-importance-envy.html" title="Applications and Data == Importance Envy?" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/04/applications-and-data-importance-envy.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQASX44cCp7ImA9WxZXEkk.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-3048679856124732</id><published>2008-02-28T19:17:00.001-05:00</published><updated>2008-02-28T19:19:08.038-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-02-28T19:19:08.038-05:00</app:edited><title>Experimenting with Connection Pooling</title><content type="html">&lt;p&gt;Connection pooling can be a great way to increase performance and scalability in your ODP.NET applications; however, it is also a feature that can be confusing to figure out as there are several parameters used in the connection string that control the behavior of the feature. These parameters are all fully documented in the documentation that ships with the data provider. In brief, the primary parameters used to control connection pooling are (see documentation for additional parameters):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Pooling - Enables or disables the connection pooling feature&lt;/li&gt;    &lt;li&gt;Min Pool Size - Specifies the minimum number of connections that can be in the pool&lt;/li&gt;    &lt;li&gt;Max Pool Size - Specifies the maximum number of connections that can be in the pool&lt;/li&gt;    &lt;li&gt;Incr Pool Size - Specifies the increment value (the number of connections) to be added if the connection pool needs to grow in size&lt;/li&gt;    &lt;li&gt;Decr Pool Size - Specifies the maximum number of connections that may be removed from the pool in a single &amp;quot;downsizing&amp;quot; operation&lt;/li&gt;    &lt;li&gt;Connection Lifetime - Specifies the amount of time that a connection must be active after which the connection will &lt;em&gt;not&lt;/em&gt; be returned to the pool (i.e. it will be disposed)&lt;/li&gt;    &lt;li&gt;Connection Timeout - Specifies the amount of time that the provider will wait for an available connection from the pool&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In ODP.NET each connection in the pool is represented by a physical connection to the database. There is a one-to-one relationship. If there are 4 connections in the pool there will be 4 corresponding connections in the database. This is another way of saying that ODP.NET connection pooling does not implement multiplexing (or sharing) of connections. Another important characteristic is that a connection pool is associated with a client process. This means that if you implement connection pooling in an application and there are 8 copies of that application simultaneously running at any given time, there will be 8 connections pools - one for each instance of the application process.&lt;/p&gt;  &lt;p&gt;Because a connection pool is associated with a specific instance of an application it can possibly be a bit difficult to test the impact and operation of the various connection string parameters related to connection pooling. I've put together a simple project that uses threads to test connection pooling. This allows the single application process to create multiple connections (and thus multiple entries in the connection pool) to the database.&lt;/p&gt;  &lt;p&gt;The sample code invokes a supplied PL/SQL procedure in the DBMS_LOCK package to sleep for a period of time (hard-coded as 30 seconds in the below code). The allows the connection to be &amp;quot;held active&amp;quot; and helps with testing the impact of the Connection Lifetime parameter. In order for this to work, the database user must be granted execution permission on the PL/SQL package. For example (as a DBA user via SQL*Plus):&lt;/p&gt;  &lt;p&gt;grant execute on dbms_lock to orademo;&lt;/p&gt;  &lt;p&gt;After starting the specified number of threads (and connections) the application holds the connection as active for the determined period of time, and then disposes of the connection object placing it back into the connection pool (depending on how you set the parameters!). In order to monitor the connections in the database, I executed the following query as a DBA user via SQL*Plus:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT&amp;#160;&amp;#160; SID,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SERIAL#,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; USERNAME,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; STATUS,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; to_char(LOGON_TIME, 'DD-MON-YY HH24:MI') LOGON_TIME      &lt;br /&gt;FROM&amp;#160;&amp;#160;&amp;#160;&amp;#160; V$SESSION      &lt;br /&gt;WHERE&amp;#160;&amp;#160;&amp;#160; LENGTH(USERNAME) &amp;gt; 1      &lt;br /&gt;ORDER BY 3, 4, 1;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The output from the application is as follows:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Thread 1 started...     &lt;br /&gt;Thread 2 started...      &lt;br /&gt;Thread 3 started...      &lt;br /&gt;Thread 4 started...      &lt;br /&gt;Thread 5 started...      &lt;br /&gt;Thread 6 started...      &lt;br /&gt;Thread 7 started...      &lt;br /&gt;Thread 8 started...      &lt;br /&gt;Thread 1 completing...      &lt;br /&gt;Thread 2 completing...      &lt;br /&gt;Thread 3 completing...      &lt;br /&gt;Thread 4 completing...      &lt;br /&gt;Thread 5 completing...      &lt;br /&gt;Thread 6 completing...      &lt;br /&gt;Thread 7 completing...      &lt;br /&gt;Thread 8 completing... &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Paused after threads complete.     &lt;br /&gt;Monitor connections using tool of choice.      &lt;br /&gt;Be sure to wait several minutes (approx. 6) for clean-up to occur. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Press Enter when finished.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It is important to execute the monitoring query while the application is &amp;quot;paused&amp;quot; otherwise the application will terminate and the connection pool will be destroyed.&lt;/p&gt;  &lt;p&gt;Here is the output of the monitoring query after the application has reached the &amp;quot;pause point&amp;quot;:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SQL&amp;gt; SELECT&amp;#160;&amp;#160; SID,     &lt;br /&gt;&amp;#160; 2&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SERIAL#,      &lt;br /&gt;&amp;#160; 3&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; USERNAME,      &lt;br /&gt;&amp;#160; 4&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; STATUS,      &lt;br /&gt;&amp;#160; 5&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; to_char(LOGON_TIME, 'DD-MON-YY HH24:MI') LOGON_TIME      &lt;br /&gt;&amp;#160; 6&amp;#160; FROM&amp;#160;&amp;#160;&amp;#160;&amp;#160; V$SESSION      &lt;br /&gt;&amp;#160; 7&amp;#160; WHERE&amp;#160;&amp;#160;&amp;#160; LENGTH(USERNAME) &amp;gt; 1      &lt;br /&gt;&amp;#160; 8&amp;#160; ORDER BY 3, 4, 1; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SID&amp;#160;&amp;#160;&amp;#160; SERIAL# USERNAME&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; STATUS&amp;#160;&amp;#160; LOGON_TIME     &lt;br /&gt;---------- ---------- ------------------------------ -------- ---------------      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 135&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 136&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 137&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 138&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 4 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 139&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 6 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 142&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 3 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 143&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 3 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 164&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 6 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 134&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2 SYSTEM&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ACTIVE&amp;#160;&amp;#160; 28-FEB-08 18:22 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;9 rows selected.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This shows the 8 connections from the 8 threads (adjustable) in the application and my SQL*Plus connection.&lt;/p&gt;  &lt;p&gt;If you simply let the application sit paused for a period of time, the connections will automatically be cleaned up by ODP.NET (again, depending on the parameter values, but the values as provided in the below code allow this to occur). On my system it took approximately 6 minutes for the connection pool to be &amp;quot;cleaned&amp;quot; (i.e. reduced to the minimum of one connection based on the values I used in the connection string).&lt;/p&gt;  &lt;p&gt;[ after waiting for about 6 minutes ]&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SQL&amp;gt; / &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SID&amp;#160;&amp;#160;&amp;#160; SERIAL# USERNAME&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; STATUS&amp;#160;&amp;#160; LOGON_TIME     &lt;br /&gt;---------- ---------- ------------------------------ -------- ---------------      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 164&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 6 ORADEMO&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INACTIVE 28-FEB-08 18:22      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 134&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2 SYSTEM&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ACTIVE&amp;#160;&amp;#160; 28-FEB-08 18:22 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;2 rows selected.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This shows the connection pool has been &amp;quot;downsized&amp;quot; to the minimum number (one) I specified.&lt;/p&gt;  &lt;p&gt;I encourage you to experiment with the different parameters and values to see how they operate and what impact they have on your system.&lt;/p&gt;  &lt;p&gt;&lt;font size="4"&gt;&lt;strong&gt;The Code&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using System;     &lt;br /&gt;using System.Threading;      &lt;br /&gt;using System.Data;      &lt;br /&gt;using Oracle.DataAccess.Client;      &lt;br /&gt;using Oracle.DataAccess.Types; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;namespace Miscellaneous     &lt;br /&gt;{      &lt;br /&gt;&amp;#160; class Program      &lt;br /&gt;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; static void Main(string[] args)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // change connection string as appropriate and experiment with different values      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; const string constr = &amp;quot;User Id=orademo; &amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Password=oracle; &amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Data Source=orademo; &amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Enlist=false;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Pooling=true;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Min Pool Size=1;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Max Pool Size=8;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Incr Pool Size=1;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Decr Pool Size=8;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Connection Lifetime=60;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Connection Timeout=5&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // set to number of threads / connections to use     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; const int numberOfThreads = 8; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create arrays for class instances and events     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ConnectionThread[] threadArray = new ConnectionThread[numberOfThreads];      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ManualResetEvent[] doneEvents = new ManualResetEvent[numberOfThreads]; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // populate arrays and start threads     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; for (int i = 0; i &amp;lt; numberOfThreads; i++)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // initialize each event object in the array      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; doneEvents[i] = new ManualResetEvent(false);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create a new instance of the ConnectionThread class      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ConnectionThread ct = new ConnectionThread(i + 1, constr, doneEvents[i]);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // assign the new instance to array element      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; threadArray[i] = ct;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Queue the thread for execution and specify the method to execute      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // when thread becomes available from the thread pool      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ThreadPool.QueueUserWorkItem(ct.ThreadPoolCallback);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // wait until all threads have completed     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WaitHandle.WaitAll(doneEvents); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // keep application from terminating while monitoring connections in database     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // if the application / process terminates all connections will be removed      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Paused after threads complete.&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Monitor connections using tool of choice.&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Be sure to wait several minutes (approx. 6) for clean-up to occur.&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.Write(&amp;quot;Press Enter when finished.&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.ReadLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160; public class ConnectionThread     &lt;br /&gt;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // private class members      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; private int _threadNumber;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; private string _constr;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; private ManualResetEvent _doneEvent; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // parameterized constructor     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public ConnectionThread(int threadNumber, string connectionString, ManualResetEvent doneEvent)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _threadNumber = threadNumber;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _constr = connectionString;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _doneEvent = doneEvent;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; // this will be called when the thread starts     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public void ThreadPoolCallback(Object threadContext)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Thread {0} started...&amp;quot;, _threadNumber); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // do some database work that holds the connection open     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DoWork(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Thread {0} completing...&amp;quot;, _threadNumber); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // signal that this thread is done     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _doneEvent.Set();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; public void DoWork()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create and open connection      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleConnection con = new OracleConnection(_constr);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Open(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // command to do the database work (simply hold connection open for 30 seconds)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // NOTE: execute privilege must be granted to user on the dbms_lock package      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleCommand cmd = con.CreateCommand();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = &amp;quot;begin dbms_lock.sleep(30); end;&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // execute the anonymous pl/sql block to does nothing but sleep to hold the connection     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.ExecuteNonQuery(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // clean up and return connection to pool (depending on connection string settings)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Dispose();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-3048679856124732?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/3048679856124732/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/02/experimenting-with-connection-pooling.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3048679856124732?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3048679856124732?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/X4_fK3U5yds/experimenting-with-connection-pooling.html" title="Experimenting with Connection Pooling" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/02/experimenting-with-connection-pooling.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEMQ34-fSp7ImA9WxZSGE8.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-3485997221427159924</id><published>2008-01-31T20:13:00.001-05:00</published><updated>2008-01-31T20:18:02.055-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-31T20:18:02.055-05:00</app:edited><title>VB, OracleCommandBuilder, and What's Wrong With This Code?</title><content type="html">&lt;p&gt;Below is some sample code. Create a new VB console application, add a reference to the Oracle.DataAccess.dll assembly, and add Oracle.DataAccess.Client to the Imported namespaces using the properties page for the project. Copy and paste the code into the .vb source file. Do you get any errors? Does it compile? Is there anything wrong with this code?&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;Module Module1     &lt;br /&gt;&amp;#160; Sub Main()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ' connection string -- change as necessary      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim constr As String = &amp;quot;User Id=scott; &amp;quot; &amp;amp; _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Password=tiger; &amp;quot; &amp;amp; _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Data Source=orademo; &amp;quot; &amp;amp; _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Enlist=false; &amp;quot; &amp;amp; _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Pooling=false&amp;quot; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ' will use below     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim ds As New DataSet      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim da As OracleDataAdapter      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim con As OracleConnection &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ' open connection     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con = New OracleConnection(constr)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; con.Open() &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ' get a data adapter for the emp table     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; da = New OracleDataAdapter(&amp;quot;select * from emp&amp;quot;, con) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ' get the schema information     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; da.FillSchema(ds, SchemaType.Source) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ' get command builder from data adapter     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim cb As New OracleCommandBuilder(da) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ' set the insert command from the command builder     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; da.InsertCommand = cb.GetInsertCommand(True) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; ' simple prompt to keep console from closing when     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ' run from within the Visual Studio environment      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;ENTER to continue...&amp;quot;)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Console.ReadLine()      &lt;br /&gt;&amp;#160; End Sub      &lt;br /&gt;End Module&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If the code compiles, when you try to run it, do you get an error? If you get an error, does it indicate: &amp;quot;The DataAdapter.SelectCommand property needs to be initialized.&amp;quot;&lt;/p&gt;  &lt;p&gt;Hmm. Strange. It looks like the SelectCommand is being initialized right there in the OracleDataAdapter constructor: da = New OracleDataAdapter(&amp;quot;select * from emp&amp;quot;, con)&lt;/p&gt;  &lt;p&gt;A quick check in the Oracle Data Provider for .NET documentation shows that the constructor for OracleDataAdapter can definitely take a string which represents the select command text and a connection object. Yet you may get an error stating that the SelectCommand property needs to be initialized.&lt;/p&gt;  &lt;p&gt;If this code compiled fine and yet you get a runtime error, here's a pointer - add the following to the top of the source code file:&lt;/p&gt;  &lt;p&gt;' Enable Option Strict checking   &lt;br /&gt;Option Strict On&lt;/p&gt;  &lt;p&gt;(You can also change this via the project property page on the Compile tab)&lt;/p&gt;  &lt;p&gt;Did anything change in the source code? In particular this part of the source code:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;' set the insert command from the command builder     &lt;br /&gt;da.InsertCommand = cb.GetInsertCommand(True)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If Option Strict is not enabled, which happens to be the default, VB will try to perform an implicit conversion from one data type to another data type with no compile-time warning. However, at runtime the conversion may fail. In addition, if you consult the ODP.NET documentation you will see that there is no OracleCommandBuilder.GetInsertCommand that takes a Boolean. However, OracleCommandBuilder inherits from System.Data.Common.DbCommandBuilder which &lt;em&gt;does&lt;/em&gt; have an overloaded GetInsertCommand that takes a Boolean.&lt;/p&gt;  &lt;p&gt;So, in the case of the (incorrect) code above, DbCommandBuilder.GetInsertCommand(Boolean) is the method that was to be invoked &lt;em&gt;not&lt;/em&gt; the OracleCommandBuilder.GetInsertCommand. This is the cause of the runtime error and explains the complaint about the select command not being initialized. If you try to compile the code with Option Strict enabled you should receive: &amp;quot;Option Strict On disallows implicit conversions from 'System.Data.Common.DbCommand' to 'Oracle.DataAccess.Client.OracleCommand'.&amp;quot;&lt;/p&gt;  &lt;p&gt;From my perspective it seems like a good idea to always enable Option Strict.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-3485997221427159924?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/3485997221427159924/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2008/01/vb-oraclecommandbuilder-and-what-wrong.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3485997221427159924?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/3485997221427159924?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/at47bpkZAuc/vb-oraclecommandbuilder-and-what-wrong.html" title="VB, OracleCommandBuilder, and What&amp;#39;s Wrong With This Code?" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://oradim.blogspot.com/2008/01/vb-oraclecommandbuilder-and-what-wrong.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YGQn05cSp7ImA9WB9bGEw.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-1264754110961184677</id><published>2007-12-27T21:49:00.001-05:00</published><updated>2007-12-27T22:05:23.329-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-27T22:05:23.329-05:00</app:edited><title>ODAC 11g Released</title><content type="html">&lt;p&gt;ODAC 11g Version 11.1.0.6.20 (including the Oracle Developer Tools for Visual Studio .NET and ODP.NET) has now been released to production.&lt;/p&gt;  &lt;p&gt;Get your download &lt;a title="ODAC 11g Download" href="http://www.oracle.com/technology/software/tech/windows/odpnet/index.html" target="_blank"&gt;here&lt;/a&gt; and check out the &lt;a title="New Features List" href="http://www.oracle.com/technology/tech/windows/odpnet/newfeatures.html" target="_blank"&gt;new features list&lt;/a&gt;!&lt;/p&gt;  &lt;p&gt;The Bulk Copy and User-Defined Types (UDT) features are likely to be well received along with the Instant Client support.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-1264754110961184677?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/1264754110961184677/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2007/12/odac-11g-released.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/1264754110961184677?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/1264754110961184677?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/C5YVho0U8fk/odac-11g-released.html" title="ODAC 11g Released" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://oradim.blogspot.com/2007/12/odac-11g-released.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQCRXs5fyp7ImA9WB9UFEQ.&quot;"><id>tag:blogger.com,1999:blog-17554078.post-489914149814904148</id><published>2007-12-12T16:52:00.001-05:00</published><updated>2007-12-12T16:52:44.527-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-12T16:52:44.527-05:00</app:edited><title>Dynamically Creating a Variable In-List</title><content type="html">&lt;p&gt;Frequently SQL statements in code use an &amp;quot;in-list&amp;quot;. That is, SQL that resembles the following:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;select&amp;#160;&amp;#160; employee_id,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; first_name,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; last_name      &lt;br /&gt;from&amp;#160;&amp;#160;&amp;#160;&amp;#160; employees      &lt;br /&gt;where&amp;#160;&amp;#160;&amp;#160; employee_id in (102,127,206)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here I am providing an in-list for the employee_id column. Using the HR sample that ships with Oracle Database, the above query returns the following results:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;EMPLOYEE_ID FIRST_NAME&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LAST_NAME     &lt;br /&gt;----------- -------------------- -------------------------      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 102 Lex&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; De Haan      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 206 William&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Gietz      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 127 James&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Landry&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Of course you may wish to vary the number of items in the in-list as well as the actual values. When the value of an item in the list changes, you may wish to use a bind variable for that item. See my Oracle Magazine column &lt;a title="The Values that Bind, Oracle Magazine" href="http://www.oracle.com/technology/oramag/oracle/05-sep/o55odpnet.html" target="_blank"&gt;here&lt;/a&gt; for more details on bind variables and why you might want to use them.&lt;/p&gt;  &lt;p&gt;The above SQL statement re-factored to use bind variables would look like:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;select&amp;#160;&amp;#160; employee_id,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; first_name,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; last_name      &lt;br /&gt;from&amp;#160;&amp;#160;&amp;#160;&amp;#160; employees      &lt;br /&gt;where&amp;#160;&amp;#160;&amp;#160; employee_id in (:0,:1,:2)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;In this re-factored statement I am still using 3 values in the in-list. This is definitely not a requirement: the in-list can contain anywhere from 1 to 1000 items. See the official Oracle documentation &lt;a title="Expression Lists" href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/expressions015.htm#i1033664" target="_blank"&gt;here&lt;/a&gt; for more details.&lt;/p&gt;  &lt;p&gt;When attempting to use an in-list with bind variables you may be tempted to supply the comma-delimited values as a single string argument to the in-list. This may resemble:&lt;/p&gt; &lt;font face="Courier New"&gt;select&amp;#160;&amp;#160; employee_id,   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; first_name,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; last_name    &lt;br /&gt;from&amp;#160;&amp;#160;&amp;#160;&amp;#160; employees    &lt;br /&gt;where&amp;#160;&amp;#160;&amp;#160; employee_id in (:0)&lt;/font&gt;  &lt;p&gt;In this case you may try to pass the string &amp;quot;102,127,206&amp;quot; as the value for the bind variable. However, this will not work as you might expect. You will receive &amp;quot;ORA-1722: invalid number&amp;quot; if you try this because the string &amp;quot;102,127,206&amp;quot; can not be converted to a numeric value. Instead you must create the statement with a separate bind variable for each item you wish to pass in the in-list.&lt;/p&gt;  &lt;p&gt;One technique to do this uses a StringBuilder object to create the SQL statement and dynamically build the in-list items. Here is some sample code that illustrates this technique:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;using System;     &lt;br /&gt;using System.Data;      &lt;br /&gt;using System.Text;      &lt;br /&gt;using Oracle.DataAccess.Client;      &lt;br /&gt;using Oracle.DataAccess.Types; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;namespace VariableInListDemo     &lt;br /&gt;{      &lt;br /&gt;&amp;#160; class Program      &lt;br /&gt;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; static void Main(string[] args)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // change connection string for your environment      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string constr = &amp;quot;User Id=hr;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Password=hr;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Data Source=orademo;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Pooling=false;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Enlist=false&amp;quot;; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // the &amp;quot;base&amp;quot; sql statement to which the in-list will be appended     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StringBuilder sbSQL = new StringBuilder(&amp;quot;select employee_id, &amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;first_name, &amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;last_name &amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;from employees &amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;where employee_id in (&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // if no command-line arguments specified, simply return     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (args.Length == 0)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;No employee_id values specified...&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;Please specify values such as: 102,127,206&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create and open connection      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleConnection con = new OracleConnection(constr);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; con.Open(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // split the command-line argument into separate tokens     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // the command-line argument should be similar to:      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // 102,127,206      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string[] EmpNos = args[0].Split(','); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // build the in-list part of the sql     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; for (int i = 0; i &amp;lt; EmpNos.Length; i++)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // append the bind variables into the sql      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbSQL.Append(&amp;quot;:&amp;quot; + i.ToString()); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // add a &amp;quot;,&amp;quot; after all but the last bind variable     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (i &amp;lt; EmpNos.Length - 1)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbSQL.Append(&amp;quot;,&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // close the in-list with the trailing &amp;quot;)&amp;quot;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; sbSQL.Append(&amp;quot;)&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create the command object     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleCommand cmd = con.CreateCommand();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.CommandText = sbSQL.ToString(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create an array of OracleParameter objects for each     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // empno specified on the command-line      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleParameter[] EmpNoParams = new OracleParameter[EmpNos.Length]; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // set the properties for each parameter     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // and add to parameters collection      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; for (int i = 0; i &amp;lt; EmpNos.Length; i++)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EmpNoParams[i] = new OracleParameter();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EmpNoParams[i].OracleDbType = OracleDbType.Decimal;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EmpNoParams[i].Value = Convert.ToDecimal(EmpNos[i]); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cmd.Parameters.Add(EmpNoParams[i]);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // create a data reader     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OracleDataReader dr = cmd.ExecuteReader(); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // iterate over the reader and display to console     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; while (dr.Read())      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(dr[0].ToString() + &amp;quot;, &amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dr[1].ToString() + &amp;quot;, &amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dr[2].ToString());      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // add clean up code as necessary for your environment &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // prevent console from closing when run from VS environment     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&amp;quot;ENTER to continue...&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.ReadLine();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Running the above sample from a console window using the values &amp;quot;102,127,206&amp;quot; produces the following results:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;C:\&amp;gt;VariableInListDemo.exe 102,127,206     &lt;br /&gt;102, Lex, De Haan      &lt;br /&gt;206, William, Gietz      &lt;br /&gt;127, James, Landry &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;ENTER to continue...&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If you need to use a variable in-list in your application, I encourage you to experiment with this technique using different values and numbers of items as a possible solution.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17554078-489914149814904148?l=oradim.blogspot.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://oradim.blogspot.com/feeds/489914149814904148/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://oradim.blogspot.com/2007/12/dynamically-creating-variable-in-list.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/489914149814904148?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/17554078/posts/default/489914149814904148?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/oradim/~3/8LzpI3d7hiM/dynamically-creating-variable-in-list.html" title="Dynamically Creating a Variable In-List" /><author><name>Mark Williams</name><uri>http://www.blogger.com/profile/11851332409410896985</uri><email>mawilliams@cheshamdbs.com</email><gd:extendedProperty name="OpenSocialUserId" value="11388447196059429024" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://oradim.blogspot.com/2007/12/dynamically-creating-variable-in-list.html</feedburner:origLink></entry></feed>
