﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-bob-文章分类-oracle</title><link>http://www.blogjava.net/keweibo/category/25620.html</link><description>&lt;script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"&gt;&lt;/script&gt;
&lt;!-- iteye 460 60 --&gt;
&lt;ins class="adsbygoogle"
     style="display:inline-block;width:468px;height:60px"
     data-ad-client="ca-pub-2876867208357149"
     data-ad-slot="0418982663"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
</description><language>zh-cn</language><lastBuildDate>Sun, 20 Sep 2015 07:51:39 GMT</lastBuildDate><pubDate>Sun, 20 Sep 2015 07:51:39 GMT</pubDate><ttl>60</ttl><item><title>ORA-54033 要修改的列由某个虚拟表达式使用</title><link>http://www.blogjava.net/keweibo/articles/427353.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Wed, 16 Sep 2015 06:30:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/427353.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/427353.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/427353.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/427353.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/427353.html</trackback:ping><description><![CDATA[<em style="text-transform: none; background-color: rgb(254,254,254); text-indent: 0px; font: 14px/21px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; float: left; letter-spacing: normal; color: rgb(153,153,153); word-spacing: 0px; -webkit-text-stroke-width: 0px">原文</em><span style="text-transform: none; background-color: rgb(254,254,254); text-indent: 0px; display: inline !important; font: 14px/21px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; float: none; letter-spacing: normal; color: rgb(153,153,153); word-spacing: 0px; -webkit-text-stroke-width: 0px">&nbsp;<span class="Apple-converted-space">&nbsp;</span></span><a style="text-transform: none; background-color: rgb(254,254,254); text-indent: 0px; text-overflow: ellipsis; display: inline-block; font: 14px/21px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; max-width: 69%; white-space: nowrap; letter-spacing: normal; color: rgb(51,51,51); overflow: hidden; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; transition: 0.25s; -webkit-transition: 0.25s" class="cut cut70" href="http://www.tuicool.com/articles/goto?id=nmQfuyB">http://blogs.oracle.com/sql/entry/ora_54033_and_the_hidden</a><br /><br />
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">A colleague recently asked me a question:</p>
<address style="text-transform: none; background-color: rgb(254,254,254); text-indent: 0px; display: block; font: 16px/1.5em 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; margin-bottom: 1.5em; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">"I'm modifying the data type of a column. When doing so I get the following error:</p>
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">ORA-54033: column to be modified is used in a virtual column expression</p>
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">But there's no virtual columns defined on the table! What on earth's going on?!"</p></address>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">This was exceptionally confusing. Looking at the table definition we couldn't see any virtual columns defined:&nbsp;</p><pre style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 0.3em; overflow-y: auto; text-transform: none; background-color: rgb(246,246,246); text-indent: 0px; margin: 0px 0px 0.75em; padding-left: 0.3em; padding-right: 0.3em; display: block; font: 12px/1.5em Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; white-space: pre-wrap; letter-spacing: normal; color: rgb(51,51,51); word-break: break-all; border-top: 1px solid; border-right: 1px solid; word-spacing: 0px; padding-top: 0.3em; -webkit-text-stroke-width: 0px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px" class="sql"><span class="operator"><span style="color: rgb(51,51,51); font-weight: bold" class="keyword">create</span> <span style="color: rgb(51,51,51); font-weight: bold" class="keyword">table</span> tab (
  x <span style="color: rgb(51,51,51); font-weight: bold" class="keyword">integer</span>, 
  y <span style="color: rgb(51,51,51); font-weight: bold" class="keyword">date</span>, 
  z varchar2(<span style="color: rgb(0,153,153)" class="number">30</span>)
);</span></pre>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">Sure enough, when we tried to change the data type of y we got the exception:</p><pre style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 0.3em; overflow-y: auto; text-transform: none; background-color: rgb(246,246,246); text-indent: 0px; margin: 0px 0px 1.5em; padding-left: 0.3em; padding-right: 0.3em; display: block; font: 12px/1.5em Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; white-space: pre-wrap; letter-spacing: normal; color: rgb(51,51,51); word-break: break-all; border-top: 1px solid; border-right: 1px solid; word-spacing: 0px; padding-top: 0.3em; -webkit-text-stroke-width: 0px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px" class="prettyprint sql"><span class="operator"><span style="color: rgb(51,51,51); font-weight: bold" class="keyword">alter</span> <span style="color: rgb(51,51,51); font-weight: bold" class="keyword">table</span> tab modify (y <span style="color: rgb(51,51,51); font-weight: bold" class="keyword">timestamp</span>);</span>

ORA-54033: column to be modified is used in a virtual column expression</pre>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">How could this be?&nbsp;</p>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">Perhaps there was a column defined that we couldn't see. Querying user_tab_cols revealed something interesting:</p><pre style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 0.3em; overflow-y: auto; text-transform: none; background-color: rgb(246,246,246); text-indent: 0px; margin: 0px 0px 1.5em; padding-left: 0.3em; padding-right: 0.3em; display: block; font: 12px/1.5em Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; white-space: pre-wrap; letter-spacing: normal; color: rgb(51,51,51); word-break: break-all; border-top: 1px solid; border-right: 1px solid; word-spacing: 0px; padding-top: 0.3em; -webkit-text-stroke-width: 0px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px" class="prettyprint sql"><span class="operator"><span style="color: rgb(51,51,51); font-weight: bold" class="keyword">select</span> column_name, data_default, hidden_column 
<span style="color: rgb(51,51,51); font-weight: bold" class="keyword">from</span>   user_tab_cols
<span style="color: rgb(51,51,51); font-weight: bold" class="keyword">where</span>  table_name = <span style="color: rgb(221,17,68)" class="string">'TAB'</span>;</span>

COLUMN_NAME <span style="white-space: pre">			</span>DATA_DEFAULT <span style="white-space: pre">			</span>HID
<span style="font-style: italic; color: rgb(153,153,136)" class="comment">------------------------------ <span style="white-space: pre">	</span>-----------------------------   ---</span>
SYS_STUYPW88OE302TFVBNC6$MMQXE<span style="white-space: pre">	</span>SYS_OP_COMBINED_HASH("X","Y")<span style="white-space: pre">	</span>YES
Z<span style="white-space: pre">		</span>                                                NO
Y<span style="white-space: pre">								</span>NO
X<span style="white-space: pre">								</span>NO</pre>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">The SYS_... column isn't in the table DDL! Where does it come from? And what's SYS_OP_COMBINED_HASH all about? Has someone been mucking around with the database?</p>
<div style="text-transform: none; background-color: rgb(254,254,254); text-indent: 0px; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">The SYS_ prefix is a sign that the column is system generated. So something's happened that's caused Oracle to create this on our behalf.</p>
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">SYS_OP_COMBINED_HASH is an undocumented feature. The name implies Oracle is merging the arguments together to form a hash.</p>
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">Is there a feature where we want to capture information about a group of columns?</p></div>
<div style="text-transform: none; background-color: rgb(254,254,254); text-indent: 0px; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">Indeed there is -extended statistics!This feature enables to Oracle calculate statistics on a group of columns. It uses this information to improve row estimates. This is useful when there's a correlation between the values of two (or more) columns in a table.</p>
<p style="line-height: 1.7em; text-indent: 1em; margin: 0px 0px 0.75em; font-size: 16px">Someone had created extended stats on this table for (x, y).</p></div>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">Now we've identified the problem, how do we get around it?</p>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">Simple: drop and recreate the extended stats:</p><pre style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 0.3em; overflow-y: auto; text-transform: none; background-color: rgb(246,246,246); text-indent: 0px; margin: 0px 0px 1.5em; padding-left: 0.3em; padding-right: 0.3em; display: block; font: 12px/1.5em Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; white-space: pre-wrap; letter-spacing: normal; color: rgb(51,51,51); word-break: break-all; border-top: 1px solid; border-right: 1px solid; word-spacing: 0px; padding-top: 0.3em; -webkit-text-stroke-width: 0px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px" class="prettyprint sql">exec dbms_stats.drop_extended_stats(user, 'tab', '(x, y)');

<span class="operator"><span style="color: rgb(51,51,51); font-weight: bold" class="keyword">alter</span> <span style="color: rgb(51,51,51); font-weight: bold" class="keyword">table</span> tab modify (y <span style="color: rgb(51,51,51); font-weight: bold" class="keyword">timestamp</span>);</span>

<span class="operator"><span style="color: rgb(51,51,51); font-weight: bold" class="keyword">select</span> dbms_stats.create_extended_stats(<span style="color: rgb(51,51,51); font-weight: bold" class="keyword">user</span>, <span style="color: rgb(221,17,68)" class="string">'tab'</span>, <span style="color: rgb(221,17,68)" class="string">'(x, y)'</span>)
<span style="color: rgb(51,51,51); font-weight: bold" class="keyword">from</span>   dual;</span>

DBMS_STATS.CREATE_EXTENDED_STATS(USER,'TAB','(X,Y)')                           
<span style="font-style: italic; color: rgb(153,153,136)" class="comment">--------------------------------------------------------------------------------</span>
SYS_STUYPW88OE302TFVBNC6$MMQXE  </pre>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">Success!</p>
<p style="text-transform: none; background-color: rgb(254,254,254); text-indent: 1em; margin: 0px 0px 0.75em; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">Extended stats are a great way to improve the optimizer's row estimates. If you need to create these, I recommend you also do the following:</p>
<div style="text-transform: none; background-color: rgb(254,254,254); text-indent: 0px; font: 16px/27px 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-stroke-width: 0px">
<ul style="padding-bottom: 0px; line-height: 1.7em; list-style-type: none; margin: 0px 0px 0.75em 25px; padding-left: 0px; padding-right: 0px; font-size: 16px; padding-top: 0px"><li style="line-height: 1.7em; list-style-type: disc; font-size: 16px">Apply the extended stats to all environments</li><li style="line-height: 1.7em; list-style-type: disc; font-size: 16px">Put a comment on the columns explaining what you've done, e.g.&nbsp;</li>
<ul style="padding-bottom: 0px; line-height: 1.7em; list-style-type: none; margin: 0px 0px 0px 25px; padding-left: 0px; padding-right: 0px; font-size: 16px; padding-top: 0px"><li style="line-height: 1.7em; list-style-type: disc; font-size: 16px">comment on column tab.x is 'part of extended stats. To modify data type drop and recreate stats';</li></ul></ul>These actions will help prevent future developers getting stuck tracking down the cause of "missing" virtual columns!</div><img src ="http://www.blogjava.net/keweibo/aggbug/427353.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2015-09-16 14:30 <a href="http://www.blogjava.net/keweibo/articles/427353.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle 十进制与十六进制的转换</title><link>http://www.blogjava.net/keweibo/articles/416374.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Wed, 30 Jul 2014 09:35:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/416374.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/416374.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/416374.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/416374.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/416374.html</trackback:ping><description><![CDATA[<p style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; font: 13px/20px georgia, verdana, Arial, helvetica, sans-seriff; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(75,75,75); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">十进制与十六进制的转换<br />8i以上版本：</p>
<p style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; font: 13px/20px georgia, verdana, Arial, helvetica, sans-seriff; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(75,75,75); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">十进制--&gt;十六进制&nbsp;<br />select to_char(100,'XX') from dual;</p>
<p style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; font: 13px/20px georgia, verdana, Arial, helvetica, sans-seriff; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(75,75,75); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">十六进制--&gt;十进制<br />select to_number('7D','XX') from dual;</p><br /><span style="color: red">其中XX为格式，注意XX的位数不能小于</span>传入的参数。<br /><img src ="http://www.blogjava.net/keweibo/aggbug/416374.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2014-07-30 17:35 <a href="http://www.blogjava.net/keweibo/articles/416374.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转: ORA-12514（TNS:监听程序当前无法识别...）的解决方案</title><link>http://www.blogjava.net/keweibo/articles/380324.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 08 Jun 2012 03:42:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/380324.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/380324.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/380324.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/380324.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/380324.html</trackback:ping><description><![CDATA[<span style="color: red; ">转:</span><span style="color: red; ">http://www.2cto.com/database/201204/126126.html</span><br /><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">在安装ORACLE 11G 过程中由于配置的原因，安装过程中报了如下错误：</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; "><br /><img src="http://www.2cto.com/uploadfile/2012/0405/20120405104617133.jpg" style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; width: 499px; height: 275px; "  alt="" /><br />&nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">按照安装提示执行后面的操作后，打开PL/SQL DEVELOPER 连接<a href="http://www.2cto.com/database/" target="_blank" style="color: #333333; text-decoration: none; ">数据库</a>时总报ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务!</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">ORACLE NET MANAGER里面测试，测试服务是否能够成功。结果还是报如上错误</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; "><br /><img src="http://www.2cto.com/uploadfile/2012/0405/20120405104617291.jpg" style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; width: 630px; height: 349.7822706065319px; "  alt="" /><br />&nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">在网上百度了一下这个错误ORA-12514，原来很多人都碰到过这个问题，于是按照别人的处理步骤依依配置了，这个问题解决了，不过还是觉得有必要把这个问题解决的步骤记录下来，一来让自己能跟深刻的体会一下，锻炼一下总结能力，二来可以帮助到以后碰到这个问题的人。</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">先找到找到listener.ora 文件,实验机器位于：E:\app\kerry\product\11.2.0\dbhome_1\NETWORK\ADMIN 目录下的listener.ora文件。问题都在这个文件上。</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">该文件初始如下所示：</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; "># listener.ora Network Configuration File: E:\app\kerry\product\11.2.0\dbhome_1\network\admin\listener.ora</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; "># Generated by&nbsp;<a href="http://www.2cto.com/database/Oracle/" target="_blank" style="color: #333333; text-decoration: none; ">Oracle</a>&nbsp;configuration tools.</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">SID_LIST_LISTENER =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; (SID_LIST =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; (SID_DESC =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (SID_NAME = CLRExtProc)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ORACLE_HOME = E:\app\kerry\product\11.2.0\dbhome_1)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (PROGRAM = extproc) &nbsp;www.2cto.com &nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ENVS = "EXTPROC_DLLS=ONLY:E:\app\kerry\product\11.2.0\dbhome_1\bin\oraclr11.dll")</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">LISTENER =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; (DESCRIPTION_LIST =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; (DESCRIPTION =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.32.106)(PORT = 1521))</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">ADR_BASE_LISTENER = E:\app\kerry</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; "><br />解决办法：</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">在 &nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp;(SID_DESC =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(SID_NAME = CLRExtProc)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(ORACLE_HOME = E:\tools\oracle\product\11.2.0\dbhome_1)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(PROGRAM = extproc)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(ENVS = "EXTPROC_DLLS=ONLY:E:\tools\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">后面添加</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(SID_DESC =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(GLOBAL_DBNAME = &nbsp;orcl.20.32.106 )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(ORACLE_HOME = E:\tools\oracle\product\11.2.0\dbhome_1)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">(SID_NAME = ORCL)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">添加后的文件内容：</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; "># listener.ora Network Configuration File: E:\app\kerry\product\11.2.0\dbhome_1\network\admin\listener.ora</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; "># Generated by Oracle configuration tools.</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">SID_LIST_LISTENER =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; (SID_LIST =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; (SID_DESC =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (SID_NAME = CLRExtProc)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ORACLE_HOME = E:\app\kerry\product\11.2.0\dbhome_1)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (PROGRAM = extproc)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ENVS = "EXTPROC_DLLS=ONLY:E:\app\kerry\product\11.2.0\dbhome_1\bin\oraclr11.dll")</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp;(SID_DESC =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (GLOBAL_DBNAME = orcl.20.32.106)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ORACLE_HOME = E:\app\kerry\product\11.2.0\dbhome_1)</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (SID_NAME = ORCL) &nbsp;www.2cto.com &nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">LISTENER =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; (DESCRIPTION_LIST =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; (DESCRIPTION =</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.32.106)(PORT = 1521))</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; &nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp; )</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">ADR_BASE_LISTENER = E:\app\kerry</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">注意SID_NAME对应网络服务命名， GLOBAL_DBNAME对应服务名。配置这些后，然后重新开启服务从新连接，OK，问题迎刃而解！</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">&nbsp;</div><div style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; color: #333333; font-family: 宋体; line-height: 28px; background-color: #ffffff; ">作者 潇湘隐者</div><img src ="http://www.blogjava.net/keweibo/aggbug/380324.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2012-06-08 11:42 <a href="http://www.blogjava.net/keweibo/articles/380324.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>查出不连续，中断的流水码</title><link>http://www.blogjava.net/keweibo/articles/344979.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Wed, 23 Feb 2011 07:55:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/344979.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/344979.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/344979.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/344979.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/344979.html</trackback:ping><description><![CDATA[今天一同事问我以下需求用SQL如何实现<br />
需求：<br />
LWH_TEST表一个SEQ栏位，对应的值（不连续的流水码）<br />
1，<br />
2，<br />
4，<br />
6，<br />
8<br />
.<br />
.<br />
.<br />
<br />
以下SQL可查出缺失的流水号：3，5，7...<br />
<br />
<strong>select b.SEQ - a.SEQ, b.SEQ, a.SEQ from <br />
( select SEQ , ROWNUM RN from (select SEQ from LWH_TEST order by SEQ) ) a, <br />
( select SEQ , ROWNUM RN from (select SEQ from LWH_TEST order by SEQ) ) b <br />
where a.RN+1 = b.RN<br />
and b.SEQ - a.SEQ &gt; 1</strong><br />
<br />
感觉还可以<br />
<br />
<img src ="http://www.blogjava.net/keweibo/aggbug/344979.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2011-02-23 15:55 <a href="http://www.blogjava.net/keweibo/articles/344979.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关联子查询与嵌套子查询</title><link>http://www.blogjava.net/keweibo/articles/337650.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 09 Nov 2010 09:25:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/337650.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/337650.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/337650.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/337650.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/337650.html</trackback:ping><description><![CDATA[<span style="color: red;">转自：http://blog.csdn.net/huangyunzeng2008/archive/2010/01/18/5209499.aspx&nbsp; </span><br />
今天优化了一个sql语句，感觉速度好像是快了点，自己想想觉得也是，下面给出类似的例子，工作中的表就不拿来举例了。实际我们平常都在凭着自己的感觉在写SQL，其实跳出那个圈子你会发现能写出更好的。
<p>一、先给出我的表和数据，这里数据量少，可能不明显，只是表明一下这个意思！</p>
<blockquote>
<div>
<pre><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=create&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">create</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=table&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">table</a> EMP
(
EMPNO    NUMBER(4) <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=not&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">not</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=null&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">null</a>,
ENAME    <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=VARCHAR&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">VARCHAR</a>2(10),
JOB      <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=VARCHAR&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">VARCHAR</a>2(9),
MGR      NUMBER(4),
HIREDATE <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=DATE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">DATE</a>,
SAL      NUMBER(7,2),
DEPTNO   NUMBER(2)
);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7369, '<span style="color: #8b0000;">SMITH</span>', '<span style="color: #8b0000;">CLERK</span>', 7902, to_date('<span style="color: #8b0000;">17-12-1980</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 800, 20);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7499, '<span style="color: #8b0000;">ALLEN</span>', '<span style="color: #8b0000;">SALESMAN</span>', 7698, to_date('<span style="color: #8b0000;">20-02-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 1600, 30);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7521, '<span style="color: #8b0000;">WARD</span>', '<span style="color: #8b0000;">SALESMAN</span>', 7698, to_date('<span style="color: #8b0000;">22-02-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 1250, 30);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7566, '<span style="color: #8b0000;">JONES</span>', '<span style="color: #8b0000;">MANAGER</span>', 7839, to_date('<span style="color: #8b0000;">02-04-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 2975, 20);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7654, '<span style="color: #8b0000;">MARTIN</span>', '<span style="color: #8b0000;">SALESMAN</span>', 7698, to_date('<span style="color: #8b0000;">28-09-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 1250, 30);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7698, '<span style="color: #8b0000;">BLAKE</span>', '<span style="color: #8b0000;">MANAGER</span>', 7839, to_date('<span style="color: #8b0000;">01-05-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 2850, 30);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7782, '<span style="color: #8b0000;">CLARK</span>', '<span style="color: #8b0000;">MANAGER</span>', 7839, to_date('<span style="color: #8b0000;">09-06-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 2450, 10);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7788, '<span style="color: #8b0000;">SCOTT</span>', '<span style="color: #8b0000;">ANALYST</span>', 7566, to_date('<span style="color: #8b0000;">19-04-1987</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 3000, 20);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7844, '<span style="color: #8b0000;">TURNER</span>', '<span style="color: #8b0000;">SALESMAN</span>', 7698, to_date('<span style="color: #8b0000;">08-09-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 1500, 30);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7876, '<span style="color: #8b0000;">ADAMS</span>', '<span style="color: #8b0000;">CLERK</span>', 7788, to_date('<span style="color: #8b0000;">23-05-1987</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 1100, 20);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7900, '<span style="color: #8b0000;">JAMES</span>', '<span style="color: #8b0000;">CLERK</span>', 7698, to_date('<span style="color: #8b0000;">03-12-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 950, 30);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7902, '<span style="color: #8b0000;">FORD</span>', '<span style="color: #8b0000;">ANALYST</span>', 7566, to_date('<span style="color: #8b0000;">03-12-1981</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 3000, 20);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO)
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a> (7934, '<span style="color: #8b0000;">MILLER</span>', '<span style="color: #8b0000;">CLERK</span>', 7782, to_date('<span style="color: #8b0000;">23-01-1982</span>', '<span style="color: #8b0000;">dd-mm-yyyy</span>'), 1300, 10);
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=commit&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">commit</a>;</pre>
</div>
</blockquote>
<p>二、假设有这样一个需求，我要得到这个表中所有低于所在部门平均工资的员工的基本信息。很自然的 我们会写出这样的SQL：</p>
<blockquote>
<div>
<pre><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> *
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> emp A
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WHERE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WHERE</a> A.sal &lt; (<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=AVG&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">AVG</a>(sal) <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> emp B <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WHERE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WHERE</a> A.deptno = B.deptno);</pre>
</div>
这种写法是很通常的写法，也很好理解，从字面上看都知道是什么意思！但是在一个很大的表中这样来统计是很慢很慢的，对于每一条记录都要嵌套的查询一个子查询，这样对性能影响是很大的。 <br />
</blockquote>
<p>三、为什么不跳出这个思维的定式，换一种方法来统计呢，我给出下面的方法：</p>
<blockquote>
<div>
<pre><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> A.*
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> emp A, (<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=SELECT&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">SELECT</a> deptno, <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=AVG&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">AVG</a>(sal) sal <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=FROM&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">FROM</a> emp <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=GROUP&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">GROUP</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=BY&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">BY</a> deptno) B
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=WHERE&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">WHERE</a> A.deptno = B.deptno
<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=AND&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">AND</a> A.sal &lt; B.sal;</pre>
</div>
<p>这里没有使用嵌套子查询，而是使用了关联子查询 ，这样实际上也是很好理解的，但是往往我们很少这样写。</p>
</blockquote>
<p>四、总的来说我还是很喜欢下面的写法，在数据量很大的情况下，对性能的提高真的不少，但是在数据量小的情况下似乎看不出什么效果。实际上也是，如果
数据量小，根本不会涉及到优化，我在这里说也没什么用。如果觉得自己的子查询有问题，看看能不能把嵌套子查询转化为关联子查询，效果还是挺明显的。 </p>
<img src ="http://www.blogjava.net/keweibo/aggbug/337650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2010-11-09 17:25 <a href="http://www.blogjava.net/keweibo/articles/337650.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle中如何进行进制转换(轉)</title><link>http://www.blogjava.net/keweibo/articles/321232.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 18 May 2010 01:44:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/321232.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/321232.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/321232.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/321232.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/321232.html</trackback:ping><description><![CDATA[<strong><span style="color: #ff0808;">轉:http://www.eygle.com/faq/Faq_convert.htm</span><br />
1.16进制转换为10进制</strong>
<p>可以通过to_number函数实现&nbsp;</p>
<table>
    <tbody>
        <tr>
            <td width="500" bgcolor="#999999">
            <p>SQL&gt; select to_number('19f','xxx') from dual;</p>
            <p>TO_NUMBER('19F','XXX')<br />
            ----------------------<br />
            415</p>
            <p>SQL&gt; select to_number('f','xx') from dual;</p>
            <p>TO_NUMBER('F','XX')<br />
            -------------------<br />
            15</p>
            </td>
        </tr>
    </tbody>
</table>
<p><strong>2.10进制转换为16进制</strong><br />
可以通过to_char函数转换</p>
<table>
    <tbody>
        <tr>
            <td width="500" bgcolor="#999999">
            <p>SQL&gt; select to_char(123,'xxx') from dual;</p>
            <p>TO_C<br />
            ----<br />
            7b</p>
            <p>SQL&gt; select to_char(4567,'xxxx') from dual;</p>
            <p>TO_CH<br />
            -----<br />
            11d7</p>
            </td>
        </tr>
    </tbody>
</table>
<p><strong>3.2进制转换为10进制</strong> </p>
<p>从Oracle9i开始,提供函数bin_to_num进行2进制到10进制的转换</p>
<table>
    <tbody>
        <tr>
            <td width="500" bgcolor="#999999">
            <p>SQL&gt; select bin_to_num(1,1,0,1) a,bin_to_num(1,0) b from dual;</p>
            <p>A B<br />
            ----- ----------<br />
            13 2</p>
            <p>SQL&gt; select bin_to_num(1,1,1,0,1) from dual;</p>
            <p>BIN_TO_NUM(1,1,1,0,1)<br />
            ---------------------<br />
            29</p>
            </td>
        </tr>
    </tbody>
</table>
<p><strong>3.进制转换也可以通过自定义函数实现</strong><br />
以下函数来自AskTom网站,是Tom给出的例子,供参考:</p>
<table>
    <tbody>
        <tr>
            <td width="500" bgcolor="#999999">
            <p>create or replace function to_base( p_dec in number, p_base in number ) <br />
            return varchar2<br />
            is<br />
            l_str varchar2(255) default NULL;<br />
            l_num number default p_dec;<br />
            l_hex varchar2(16) default '0123456789ABCDEF';<br />
            begin<br />
            if ( trunc(p_dec) &lt;&gt; p_dec OR p_dec &lt; 0 ) then<br />
            raise PROGRAM_ERROR;<br />
            end if;<br />
            loop<br />
            l_str := substr( l_hex, mod(l_num,p_base)+1, 1 ) || l_str;<br />
            l_num := trunc( l_num/p_base );<br />
            exit when ( l_num = 0 );<br />
            end loop;<br />
            return l_str;<br />
            end to_base;<br />
            /</p>
            <p><br />
            create or replace function to_dec<br />
            ( p_str in varchar2, <br />
            p_from_base in number default 16 ) return number<br />
            is<br />
            l_num number default 0;<br />
            l_hex varchar2(16) default '0123456789ABCDEF';<br />
            begin<br />
            for i in 1 .. length(p_str) loop<br />
            l_num := l_num * p_from_base + instr(l_hex,upper(substr(p_str,i,1)))-1;<br />
            end loop;<br />
            return l_num;<br />
            end to_dec;<br />
            /<br />
            show errors</p>
            <p>create or replace function to_hex( p_dec in number ) return varchar2<br />
            is<br />
            begin<br />
            return to_base( p_dec, 16 );<br />
            end to_hex;<br />
            /<br />
            create or replace function to_bin( p_dec in number ) return varchar2<br />
            is<br />
            begin<br />
            return to_base( p_dec, 2 );<br />
            end to_bin;<br />
            /<br />
            create or replace function to_oct( p_dec in number ) return varchar2<br />
            is<br />
            begin<br />
            return to_base( p_dec, 8 );<br />
            end to_oct;<br />
            /</p>
            </td>
        </tr>
    </tbody>
</table>
<p>-The End-</p>
<br />
<br />
<img src ="http://www.blogjava.net/keweibo/aggbug/321232.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2010-05-18 09:44 <a href="http://www.blogjava.net/keweibo/articles/321232.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle 10G正則表達式</title><link>http://www.blogjava.net/keweibo/articles/313432.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Sat, 20 Feb 2010 00:48:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/313432.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/313432.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/313432.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/313432.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/313432.html</trackback:ping><description><![CDATA[/*<br />
ORACLE中的支持正则表达式的函数主要有下面四个：<br />
1，REGEXP_LIKE ：与LIKE的功能相似<br />
2，REGEXP_INSTR ：与INSTR的功能相似<br />
3，REGEXP_SUBSTR ：与SUBSTR的功能相似<br />
4，REGEXP_REPLACE ：与REPLACE的功能相似<br />
它们在用法上与Oracle SQL 函数LIKE、INSTR、SUBSTR 和REPLACE 用法相同，<br />
但是它们使用POSIX 正则表达式代替了老的百分号（%）和通配符（_）字符。<br />
POSIX 正则表达式由标准的元字符（metacharacters）所构成：<br />
'^' 匹配输入字符串的开始位置，在方括号表达式中使用，此时它表示不接受该字符集合。<br />
'$' 匹配输入字符串的结尾位置。如果设置了 RegExp 对象的 Multiline 属性，则 $ 也匹<br />
配 '\n' 或 '\r'。<br />
'.' 匹配除换行符之外的任何单字符。<br />
'?' 匹配前面的子表达式零次或一次。<br />
'+' 匹配前面的子表达式一次或多次。<br />
'*' 匹配前面的子表达式零次或多次。<br />
'|' 指明两项之间的一个选择。例子'^([a-z]+|[0-9]+)$'表示所有小写字母或数字组合成的<br />
字符串。<br />
'( )' 标记一个子表达式的开始和结束位置。<br />
'[]' 标记一个中括号表达式。<br />
'{m,n}' 一个精确地出现次数范围，m=&lt;出现次数&lt;=n，'{m}'表示出现m次，'{m,}'表示至少<br />
出现m次。<br />
\num 匹配 num，其中 num 是一个正整数。对所获取的匹配的引用。<br />
字符簇： <br />
[[:alpha:]] 任何字母。<br />
[[:digit:]] 任何数字。<br />
[[:alnum:]] 任何字母和数字。<br />
[[:space:]] 任何白字符。<br />
[[:upper:]] 任何大写字母。<br />
[[:lower:]] 任何小写字母。<br />
[[:punct:]] 任何标点符号。<br />
[[:xdigit:]] 任何16进制的数字，相当于[0-9a-fA-F]。<br />
各种操作符的运算优先级<br />
\转义符<br />
(), (?:), (?=), [] 圆括号和方括号<br />
*, +, ?, {n}, {n,}, {n,m} 限定符<br />
^, $, anymetacharacter 位置和顺序<br />
| <br />
*/<br />
--创建表<br />
create table fzq<br />
(<br />
&nbsp; id varchar(4),<br />
&nbsp; value varchar(10)<br />
);<br />
--数据插入<br />
insert into fzq values<br />
('1','1234560');<br />
insert into fzq values<br />
('2','1234560');<br />
insert into fzq values<br />
('3','1b3b560');<br />
insert into fzq values<br />
('4','abc');<br />
insert into fzq values<br />
('5','abcde');<br />
insert into fzq values<br />
('6','ADREasx');<br />
insert into fzq values<br />
('7','123&nbsp; 45');<br />
insert into fzq values<br />
('8','adc&nbsp; de');<br />
insert into fzq values<br />
('9','adc,.de');<br />
insert into fzq values<br />
('10','1B');<br />
insert into fzq values<br />
('10','abcbvbnb');<br />
insert into fzq values<br />
('11','11114560');<br />
insert into fzq values<br />
('11','11124560');<br />
--regexp_like<br />
--查询value中以1开头60结束的记录并且长度是7位<br />
select * from fzq where value like '1____60';<br />
select * from fzq where regexp_like(value,'1....60');<br />
--查询value中以1开头60结束的记录并且长度是7位并且全部是数字的记录。<br />
--使用like就不是很好实现了。<br />
select * from fzq where regexp_like(value,'1[0-9]{4}60');<br />
-- 也可以这样实现，使用字符集。<br />
select * from fzq where regexp_like(value,'1[[:digit:]]{4}60');<br />
-- 查询value中不是纯数字的记录<br />
select * from fzq where not regexp_like(value,'^[[:digit:]]+$');<br />
-- 查询value中不包含任何数字的记录。<br />
select * from fzq where regexp_like(value,'^[^[:digit:]]+$');<br />
--查询以12或者1b开头的记录.不区分大小写。<br />
select * from fzq where regexp_like(value,'^1[2b]','i');<br />
--查询以12或者1b开头的记录.区分大小写。<br />
select * from fzq where regexp_like(value,'^1[2B]');<br />
-- 查询数据中包含空白的记录。<br />
select * from fzq where regexp_like(value,'[[:space:]]');<br />
--查询所有包含小写字母或者数字的记录。<br />
select * from fzq where regexp_like(value,'^([a-z]+|[0-9]+)$');<br />
--查询任何包含标点符号的记录。<br />
select * from fzq where regexp_like(value,'[[:punct:]]');<br />
/*<br />
理解它的语法就可以了。其它的函数用法类似。<br />
*/
<br />
作者：唐山人，姓方，索性就叫tshfang。喜欢计算机，喜欢读书尤其是史书。技术共享，大家方便，让我们一起创造一个自由空间。<br />
工作领域：ERP系统、计算机编程 <br />
文章来源：<a href="http://www.nipei.com/" title="文章写作">泥胚文章写作网</a> http://www.nipei.com &nbsp;&nbsp;原文地址：http://www.nipei.com/article/9865<br />
<font color="red">转载本文章必须保留作者、出处链接以及本声明。</font><br />
<font color="red"><strong>转载不注明出处、程序采集是侵权行为，我们保留追究其一切责任的权利。</strong></font>
<img src ="http://www.blogjava.net/keweibo/aggbug/313432.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2010-02-20 08:48 <a href="http://www.blogjava.net/keweibo/articles/313432.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle計算一年中53個周分別的起始與結束日期</title><link>http://www.blogjava.net/keweibo/articles/310472.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 22 Jan 2010 01:38:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/310472.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/310472.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/310472.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/310472.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/310472.html</trackback:ping><description><![CDATA[<strong><span style="color: #2708ff;">根據給定的周數,計算本周的起始和結束日期</span></strong><br />
SELECT&nbsp;&nbsp; NEXT_DAY(TO_DATE('20100101', 'yyyymmdd'),'星期一') + 1 * 7 - 7 AS first_day,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NEXT_DAY(TO_DATE('20100101', 'yyyymmdd'),'星期一') + 1 * 7 - 1 AS LAST_DAY<br />
&nbsp; FROM DUAL;<br />
<span style="color: #2000ff;"><br />
<strong>計算一年中53個周分別的起始與結束日期</strong></span><br />
SELECT tab_1.COLUMN_VALUE,<br />
&nbsp;&nbsp; NEXT_DAY(TO_DATE('<span style="color: red;">0101</span>', 'mmdd'),'星期一') + tab_1.COLUMN_VALUE * 7 - 7 AS first_day,<br />
&nbsp;&nbsp; NEXT_DAY(TO_DATE('<span style="color: red;">0101</span>', 'mmdd'),'星期一') + tab_1.COLUMN_VALUE * 7 - 1 AS LAST_DAY<br />
&nbsp; FROM TABLE<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SELECT SPLIT
('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53',
',')<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM DUAL<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) tab_1<br />
<br />
其中SPLIT为自定义函数，用于切分字符串
<img src ="http://www.blogjava.net/keweibo/aggbug/310472.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2010-01-22 09:38 <a href="http://www.blogjava.net/keweibo/articles/310472.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令</title><link>http://www.blogjava.net/keweibo/articles/308932.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Sun, 10 Jan 2010 11:44:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/308932.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/308932.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/308932.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/308932.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/308932.html</trackback:ping><description><![CDATA[<p><br />
</p>
<p>Oracle数据导入导出imp/exp就相当于oracle数据还原与备份。exp命令可以把数据从远程数据库服务器导出到本地的dmp文
件，imp命令可以把dmp文件从本地导入到远处的数据库服务器中。 利用这个功能可以构建两个相同的数据库，一个用来测试，一个用来正式使用。<br />
&nbsp;<br />
执行环境：可以在SQLPLUS.EXE或者DOS（命令行）中执行，<br />
&nbsp;DOS中可以执行时由于 在oracle 8i 中&nbsp; 安装目录ora81BIN被设置为全局路径，<br />
&nbsp;该目录下有EXP.EXE与IMP.EXE文件被用来执行导入导出。<br />
&nbsp;oracle用java编写，SQLPLUS.EXE、EXP.EXE、IMP.EXE这两个文件有可能是被包装后的类文件。<br />
&nbsp;SQLPLUS.EXE调用EXP.EXE、IMP.EXE所包裹的类，完成导入导出功能。<br />
&nbsp;<br />
下面介绍的是导入导出的实例。<br />
数据导出：<br />
&nbsp;1 将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中<br />
&nbsp;&nbsp; exp system/manager@TEST file=d:\daochu.dmp full=y<br />
&nbsp;2 将数据库中system用户与sys用户的表导出<br />
&nbsp;&nbsp; exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)<br />
&nbsp;3 将数据库中的表inner_notify、notify_staff_relat导出<br />
&nbsp;&nbsp;&nbsp; exp aichannel/aichannel@TESTDB2 file= d:\datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat)&nbsp;<br />
&nbsp;4 将数据库中的表table1中的字段filed1以"00"打头的数据导出<br />
&nbsp;&nbsp; exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=" where filed1 like '00%'"<br />
&nbsp;<br />
&nbsp; 上面是常用的导出，对于压缩，既用winzip把dmp文件可以很好的压缩。<br />
&nbsp; 也可以在上面命令后面 加上 compress=y 来实现。<br />
<br />
数据的导入<br />
&nbsp;1 将D:\daochu.dmp 中的数据导入 TEST数据库中。<br />
&nbsp;&nbsp; imp system/manager@TEST&nbsp; file=d:\daochu.dmp<br />
&nbsp;&nbsp; imp aichannel/aichannel@TEST&nbsp; full=y&nbsp; file=d:\datanewsmgnt.dmp ignore=y<br />
&nbsp;&nbsp; 上面可能有点问题，因为有的表已经存在，然后它就报错，对该表就不进行导入。<br />
&nbsp;&nbsp; 在后面加上 ignore=y 就可以了。<br />
&nbsp;2 将d:daochu.dmp中的表table1 导入<br />
&nbsp;imp system/manager@TEST&nbsp; file=d:\daochu.dmp&nbsp; tables=(table1)<br />
&nbsp;<br />
&nbsp;基本上上面的导入导出够用了。不少情况要先是将表彻底删除，然后导入。<br />
&nbsp;<br />
注意：<br />
&nbsp;操作者要有足够的权限，权限不够它会提示。<br />
&nbsp;数据库时可以连上的。可以用tnsping TEST 来获得数据库TEST能否连上。<br />
<br />
附录一：<br />
&nbsp;给用户增加导入数据权限的操作<br />
&nbsp;第一,启动sql*puls<br />
&nbsp;第二，以system/manager登陆<br />
&nbsp;第三，create user 用户名 IDENTIFIED BY 密码 （如果已经创建过用户，这步可以省略）<br />
&nbsp;第四，GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,<br />
&nbsp;&nbsp; DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBA,CONNECT,RESOURCE,CREATE SESSION&nbsp; TO 用户名字<br />
&nbsp;第五, 运行-cmd-进入dmp文件所在的目录,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imp userid=system/manager full=y file=*.dmp<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 或者 imp userid=system/manager full=y file=filename.dmp<br />
<br />
&nbsp;执行示例:<br />
&nbsp;F:WorkOracle_Databackup&gt;imp userid=test/test full=y file=inner_notify.dmp<br />
<br />
屏幕显示<br />
Import: Release 8.1.7.0.0 - Production on 星期四 2月 16 16:50:05 2006<br />
(c) Copyright 2000 Oracle Corporation.&nbsp; All rights reserved.<br />
<br />
连接到: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production<br />
With the Partitioning option<br />
JServer Release 8.1.7.0.0 - Production<br />
<br />
经由常规路径导出由EXPORT:V08.01.07创建的文件<br />
已经完成ZHS16GBK字符集和ZHS16GBK NCHAR 字符集中的导入<br />
导出服务器使用UTF8 NCHAR 字符集 (可能的ncharset转换)<br />
. 正在将AICHANNEL的对象导入到 AICHANNEL<br />
. . 正在导入表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "INNER_NOTIFY"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4行被导入<br />
准备启用约束条件...<br />
成功终止导入，但出现警告。<br />
<br />
&nbsp;<br />
附录二：<br />
&nbsp;Oracle 不允许直接改变表的拥有者, 利用Export/Import可以达到这一目的.<br />
&nbsp; 先建立import9.par,<br />
&nbsp; 然后，使用时命令如下：imp parfile=/filepath/import9.par<br />
&nbsp; 例 import9.par 内容如下：<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROMUSER=TGPMS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TOUSER=TGPMS2&nbsp;&nbsp;&nbsp;&nbsp; （注：把表的拥有者由FROMUSER改为TOUSER，FROMUSER和TOUSER的用户可以不同）&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ROWS=Y<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INDEXES=Y<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GRANTS=Y<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONSTRAINTS=Y<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BUFFER=409600<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file==/backup/ctgpc_20030623.dmp<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log==/backup/import_20030623.log <br />
<br />
</p>
<p>在导入导出命令中加上feedback=1000可以让过程显示一个不断增多的&#8220;...&#8221;，以改变以往的闪烁的光标 </p>
<p><strong style="font-size: 14pt;">New:</strong></p>
<p>exp/imp已经很好用了，但是唯一的确定是速度太慢，如果1张表的数据有个百千万的，常常导入导出就长时间停在这个表这，但是从Oracle 10g开始提供了称为数据泵新的工具expdp/impdp，它为Oracle数据提供高速并行及大数据的迁移。</p>
<p>&nbsp;imp/exp可以在客户端调用，但是expdp/impdp只能在服务端，因为在使用expdp/impdp以前需要在数据库中创建一个Directory</p>
<p>create directory dump_test as '/u01/oracle10g'；</p>
<p>grant read, write on directory dump_test to piner <br />
</p>
<p>然后就可以开始导入导出</p>
<p>expdp piner/piner directory=dump_test dumpfile=user.dmp&nbsp; 导出用户的数据<br />
</p>
<p>expdp piner/piner directory=dump_test dumpfile=table.dmp tables=test1,test2 导出表数据<br />
</p>
<p>impdp piner/piner directory=dump_test dumpfile=user.dmp 导入该用户数据<br />
</p>
impdp piner/piner directory=dump_test dumpfile=table.dmp&nbsp; 导出表数据
<img src ="http://www.blogjava.net/keweibo/aggbug/308932.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2010-01-10 19:44 <a href="http://www.blogjava.net/keweibo/articles/308932.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux主机下配置Oracle 10G自动启动过程记(转)</title><link>http://www.blogjava.net/keweibo/articles/308056.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Sat, 02 Jan 2010 15:43:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/308056.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/308056.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/308056.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/308056.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/308056.html</trackback:ping><description><![CDATA[<br />
Linux主机下配置Oracle 10G自动启动过程记<br />
一、使用root用户修改/etc/oratab 文件：<br />
$ gedit /etc/oratab<br />
orcl:/oracle/app/product/10.2.0/db_1:N<br />
改为：<br />
orcl:/oracle/app/product/10.2.0/db_1:Y<br />
也就是将最后的N改为Y<br />
二、使用Oracle用户修改$ORACLE_HOME/bin/dbstart文件：<br />
# su - oracle<br />
$ cd $ORACLE_HOME/bin<br />
$ gedit dbstart<br />
找到 ORACLE_HOME_LISTNER=.....这行， 修改成<br />
ORACLE_HOME_LISTNER=/u01/app/oracle/product/10.1.0/db_1<br />
或者直接修改成：<br />
ORACLE_HOME_LISTNER=$ORACLE_HOME<br />
注意：是修改，不是增加，可是使用gedit的查找功能查找：<br />
ORACLE_HOME_LISTNER，然后进行修改，修改后保存<br />
三、测试运行 dbshut, dbstart 看能否启动Oracle 服务及listener服务:<br />
1.修改dbstart和dbshut的日志文件的权限：<br />
$su - root<br />
#cd $ORACLE_HOME<br />
#chown oracle:oinstall startup.log<br />
#chown oracle:oinstall shutdown.log<br />
2.执行相应的脚本进行测试<br />
#su - oracle<br />
$cd $ORACLE_HOME/bin<br />
$./dbstart (./dbshut)<br />
$ ps -efw | grep ora_<br />
$ lsnrctl status<br />
$ ps -efw | grep LISTEN | grep -v grep<br />
四：创建服务<br />
$su - root<br />
# cd /etc/rc.d/init.d/<br />
# gedit oradbstart<br />
复制如下脚本1或者脚本2内容到oradbstart文件：<br />
注意点<br />
(1).#开始的行不能少，否则后面运行chkconfig命令会报错：oradbstart 服务不支持chkconfig<br />
(2).根据自己的环境修改环境变量配置部分<br />
(3).从windows下面保存的如下脚本内容，通过ISO复制到linux，再将脚本复制到oradbstart文件中后，在终端下用vi oradbstart命<br />
令打开，一些行后面可能有类似^M的字符，将其删除，否则在运行后面的chkconfig命令后，在/etc/rc.d/rcN.d目录(N为运行级别)<br />
下生成的S99oradbstart文件是空的，可以用vi查看S99oradbstart文件，内容应该和/etc/rc.d/init.d/oradbstart文件内容相同才<br />
是正确的<br />
(第三种情况是我在xp下使用虚拟机VMWARE安装linux，并将如下脚本保存成文本文件，然后制作成ISO文件，然后把ISO里面的文件的<br />
内容复制到oradbstart时遇到的，这种情况一些行后面类似^M的字符，用gedit无法看到，只有使用vi才能看到)<br />
--脚本1<br />
#!/bin/bash<br />
# chkconfig: 345 99 10<br />
# description: Startup Script for Oracle Databases<br />
# /etc/rc.d/init.d/dbstart<br />
export ORACLE_BASE=/u01/app/oracle/<br />
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1<br />
export ORACLE_SID=orcl<br />
export PATH=$PATH:$ORACLE_HOME/bin<br />
ORA_OWNR="oracle"<br />
# if the executables do not exist -- display error<br />
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]<br />
then<br />
echo "Oracle startup: cannot start"<br />
exit 1<br />
fi<br />
# depending on parameter -- startup, shutdown, restart<br />
# of the instance and listener or usage display<br />
case "$1" in<br />
start)<br />
# Oracle listener and instance startup<br />
echo -n "Starting Oracle: "<br />
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"<br />
touch /var/lock/Oracle<br />
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"<br />
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl start"<br />
echo "OK"<br />
;;<br />
stop)<br />
# Oracle listener and instance shutdown<br />
echo -n "Shutdown Oracle: "<br />
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"<br />
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl stop"<br />
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"<br />
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"<br />
rm -f /var/lock/Oracle<br />
echo "OK"<br />
;;<br />
reload|restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: `basename $0` start|stop|restart|reload"<br />
exit 1<br />
esac<br />
exit 0<br />
--脚本2（只启动数据库和听）<br />
#!/bin/bash<br />
# chkconfig: 345 99 10<br />
# description: Startup Script for Oracle Databases<br />
# /etc/rc.d/init.d/oradbstart<br />
export ORACLE_BASE=/u01/app/Oracle/<br />
export ORACLE_HOME=/u01/app/Oracle/product/10.2.0/db_1<br />
export ORACLE_SID=orcl<br />
export PATH=$PATH:$ORACLE_HOME/bin<br />
case "$1" in<br />
start)<br />
su Oracle -c $ORACLE_HOME/bin/dbstart<br />
touch /var/lock/Oracle<br />
echo "OK"<br />
;;<br />
stop)<br />
echo -n "Shutdown Oracle: "<br />
su Oracle -c $ORACLE_HOME/bin/dbshut<br />
rm -f /var/lock/Oracle<br />
echo "OK"<br />
;;<br />
*)<br />
echo "Usage: 'basename $0' start|stop"<br />
exit 1<br />
esac<br />
exit 0<br />
保存退出。<br />
打开终端执行:<br />
$su - root<br />
#chown oracle.oinstall /etc/rc.d/init.d/oradbstart<br />
#chmod 775 /etc/rc.d/init.d/oradbstart<br />
然后执行：<br />
chkconfig --add oradbstart<br />
chkconfig --list oradbstart<br />
chkconfig --list oradbstart运行结果：<br />
oradbstart 0:off 1:off 2:off 3:on 4:on 5:on 6:off<br />
五.检查：<br />
根据上面的运行结果，当相应的运行级别为on时(例如：5:on)，在对应的/etc/rc.d/rcN.d(例如：和5:on对应的<br />
是：/etc/rc.d/rc5.d)下面会生成一个文件：S99oradbstart，使用vi S99oradbstart打开该文件，可以看到该文件的内容<br />
和/etc/rc.d/init.d/oradbstart内容相同，表示配置成功，其实，S99oradbstart是一个到/etc/rc.d/init.d/oradbstart的链接，<br />
我们可以使用file命令来查看：<br />
$file /etc/rc.d/rc5.d/S99oradbstart<br />
S99oradbstart:symbolic link to '../init.d/oradbstart<br />
六.一点说明：<br />
脚本文件中的：# chkconfig: 345 99 10<br />
指出3，4，5级别启动这个服务，99是在相应的/etc/rc.d/rcN.d(N为前面指定的级别，这里是345)目录下生成的链接文件的序号(启<br />
动优先级别)S99oradbstart，10为在除前面指出的级别对应的/etc/rc.d/rcN.d(N为除345之外的级别)目录生成的链接文件的序号(服<br />
务停止的优先级别)K10oradbstart。
<img src ="http://www.blogjava.net/keweibo/aggbug/308056.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2010-01-02 23:43 <a href="http://www.blogjava.net/keweibo/articles/308056.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu9.04下安装Oracle10.2(轉)</title><link>http://www.blogjava.net/keweibo/articles/307781.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Wed, 30 Dec 2009 08:09:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/307781.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/307781.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/307781.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/307781.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/307781.html</trackback:ping><description><![CDATA[本来一开始打算弄个Oracle XE
玩玩也就行了，而且还有Debian版本的下载，在ubuntu安装个肯定也容易，结果试了一下，总时有些问题莫名其妙，所以就干脆搞个真正的企业版安装
下，反正以前也安装成功过，可惜没有完整总结记录下来，这下也正好可以总结一下。<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp; 注意：<span style="color: #ff0000;">Oracle
安装的Linux版本中，已经通过Oracle认证的有RedHat、Suse、Unbreakable
Linux、asianux。如果安装的linux系统是上面linux版本之一，最好去oracle官方文档去查阅，本文仅仅限于
Ubuntu9.04,不同的版本也会有些许不同。</span><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本文主要参考了Ubuntu论坛上的一篇ubuntu 8.10 安装Oracle 10G 企业版综合指南<br />
http://forum.ubuntu.org.cn/viewtopic.php?f=44&amp;t=170399&amp;sid=0fcf8acc5269b19e513e2249edacd886&amp;start=0<br />
在此表示感谢！<br />
<br />
一、验证安装Oracle 数据库 10g 第 2 版的系统要求<br />
<br />
按照Oracle官方指南，首先需要验证RAM和交换空间大小<br />
要查看可用 RAM 和交换空间大小，运行以下命令：<br />
grep MemTotal /proc/meminfo<br />
grep SwapTotal /proc/meminfo<br />
<br />
我本机的例子：<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ grep MemTotal /proc/meminfo</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">MemTotal:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2060248 kB</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ grep SwapTotal /proc/meminfo</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">SwapTotal:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2088408 kB</span><br />
<br />
根
据oracle官方网站的安装说明要求：所需最小 RAM 为 1,024MB，而所需最小交换空间为 1GB。对于 RAM 小于或等于 2GB
的系统，交换空间应为 RAM 数量的两倍；对于 RAM 大于 2GB 的系统，交换空间应为 RAM 数量的一到两倍。<br />
<br />
Oracle 数据库 10g 第 2 版软件还需要 2.5GB 的可用磁盘空间，而数据库则另需 1.2GB 的可用磁盘空间。/tmp 目录至少需要 400MB 的可用空间。要检查系统上的可用磁盘空间，运行以下命令：<br />
df -h<br />
我本机的例子：<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ df -h</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">文件系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 容量&nbsp; 已用 可用 已用% 挂载点</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">/dev/sda7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 27G&nbsp;&nbsp; 11G&nbsp;&nbsp; 15G&nbsp; 44% /</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1006M&nbsp;&nbsp;&nbsp;&nbsp; 0 1006M&nbsp;&nbsp; 0% /lib/init/rw</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">varrun&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1006M&nbsp; 104K 1006M&nbsp;&nbsp; 1% /var/run</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">varlock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1006M&nbsp;&nbsp;&nbsp;&nbsp; 0 1006M&nbsp;&nbsp; 0% /var/lock</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">udev&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1006M&nbsp; 188K 1006M&nbsp;&nbsp; 1% /dev</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1006M&nbsp; 208K 1006M&nbsp;&nbsp; 1% /dev/shm</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">lrm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1006M&nbsp; 2.4M 1004M&nbsp;&nbsp; 1% /lib/modules/2.6.28-11-generic/volatile</span><br />
<br />
可以看到根文件系统可用空间为15G，大于必须的（2.5 + 1.2 + 0.4 = 4.1GB）。<br />
<br />
此外可能需要事先安装包libaio1，因为一开始安装Oracle XE时，需要安装的当时就安装上了，这个未加验证。<br />
而且最好开启root用户，因为Ubuntu默认是关闭root用户的，但是在oracle的安装过程中，需要root用户来执行两个脚本。<br />
&nbsp;如果需要安装libaio1，可以通过下面来安装<br />
&nbsp;<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo apt-get install libaio1</span><br />
开启root<br />
&nbsp;<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo passwd root</span><br />
按照提示输入新密码即可。<br />
二、创建用户<br />
oracle要用oracle用户安装，安装好后，同样用oracle用户启动。<br />
//创建用户组oinstall<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo addgroup oinstall </span><br />
//创建用户组dba<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo addgroup dba</span><br />
//创建用户组nobody<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo addgroup nobody</span><br />
<br />
//将用户oracle的初始组设为oinstall,并加入到组dba中，home目录设为/home/oracle.此目录如果不存在则自动创建，shell为bash。<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo useradd -g oinstall -G dba -d /home/oracle -m -s /bin/bash oracle</span><br />
//查看nobody用户所在的组<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ id nobody</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">uid=65534(nobody) gid=65534(nogroup) 组=65534(nogroup)</span><br />
//将nobody用户加入到nobody组里面<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo usermod -G nobody nobody</span><br />
//核实nobody加入的组里面有组nobody<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ id nobody</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">uid=65534(nobody) gid=65534(nogroup) 组=65534(nogroup),1003(nobody)</span><br />
//设置用户oracle密码<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo passwd oracle</span><br />
<br />
三、创建目录。<br />
//建立oracle_base目录，如果不存在，就创建，oracle安装于此。<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo mkdir -p /opt/oracle10</span><br />
//将此目录及其下的文件或者目录的所有者改为oinstall组的oracle<br style="color: #0000ff;" />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo chown -R oracle:oinstall /opt/oracle10/</span><br />
//将此目录及其下文件权限设为755<br style="color: #0000ff;" />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo chmod -R 775 /opt/oracle10/</span><br />
<br />
四、修改内核参数<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo gedit /etc/sysctl.conf</span><br />
将以下部分，增加到文件末尾，并保存。<br />
<span style="color: #0000ff;"># special setting for oracle XE</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">&nbsp;kernel.shmmax = 536870912</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">&nbsp;kernel.shmmni = 4096</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">&nbsp;kernel.shmall = 2097152</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">&nbsp;kernel.sem = 250 32000 100 128</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">&nbsp;fs.file-max = 65536</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">&nbsp;net.ipv4.ip_local_port_range = 1024 65000</span><br />
//使设置生效<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo sysctl -p</span><br />
<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo gedit /etc/security/limits.conf </span><br />
在文件末尾最后一行＃end 之前加入下面内容。<br />
<span style="color: #0000ff;">#setting for oracle 10g</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">oracle soft nofile 65536</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">oracle hard nofile 65536</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">oracle soft nproc 16384</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">oracle hard nproc 16384</span><br />
<br />
<br />
五、创建链接及Red Hat release：<br />
//创建一些Oracle安装程序需要的工具的连接。 因为Oracle安装程序是为通过Oracle认证的Red Hat、Suse等版本准备的，所以有些工具的位置和Ubuntu不一样。<br />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo ln -s /usr/bin/awk /bin/awk</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo ln -s /usr/bin/rpm /bin/rpm</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">dhn@dhn-laptop:~$ sudo ln -s /usr/bin/basename /bin/basename</span><br />
<br />
建立redhat的release<br />
因为Oracle默认是不支持Ubuntu的，所以要把Ubuntu伪装成Redhat<br />
<span style="color: #0000ff;">dhn@dhn-laptop:/etc$ sudo touch redhat-release</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">dhn@dhn-laptop:/etc$ sudo gedit redhat-release </span><br />
在文件内增加内容：<br />
<span style="color: #0000ff;">Red Hat Linux release 4.1</span><br />
<br />
六、//使Java环境可以正常显示中文。这样在安装oracle时候的界面上的中文就不会出现乱码了。<br />
<span style="color: #0000ff;">$ cd $JAVA_HOME/jre/lib/fonts</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">$ sudo mkdir fallback</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">$ ln -s /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">$ sudo&nbsp; mkfontdir</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">$ sudo mkfontscale</span><br />
<br />
七、用oracle用户登录X<br />
进入安装文件目录<br />
<span style="color: #0000ff;">oracle@dhn-laptop:~$ ./runInstaller -jreLoc $JAVA_HOME/jre/</span><br />
<br />
注
意：此处安装程序后面增加了-jreLoc的参数，因为刚刚我们更改了本地已经安装的jre，使之能够支持中文显示，这里的意思是使用我们修改后的
jre，这样Oracle安装界面中文就可以基本显示正常了。虽然在安装Database config assistant
时候弹出的界面仍然会出现乱码，但影响不大，我记得好像就2个页面。<br />
如果不加此参数，oracle会使用自己的jre，但是这样安装界面中文就出现了乱码，当然也可以通过先执行下export LC_CTYPE=en_US.UTF-8，再运行 runinstaller 进入全英文安装界面。<br />
<span style="color: #0000ff;">oracle@dhn-laptop:~$ export LC_CTYPE=en_US.UTF-8</span><br />
<br />
以下为我个人设置<br />
产品清单目录完整路径 :/opt/oracle10<br />
操作系统组:oinstall<br />
ORACLE_HOME:/opt/oracle10/product/10.2.0/db_1<br />
全局数据库名称：orcl<br />
sid：orcl<br />
数据库字符集： ZHS16GBK<br />
存储选择 :文件系统<br />
数据文件位置：/opt/oracle10/product/10.2.0/oradata/<br />
安装会话日志： /opt/oracle10/logs/installActions2009-06-21_08-37-14AM.log<br />
<br />
安装过程中还会出现一个警告，详细看日志文件，才发现：<br />
<span style="color: #ff0000;">信息: gcc: /usr/lib/libstdc++.so.5：没有该文件或目录</span><br />
<br />
//查看/usr/lib下libstdc++是否存在<br />
<span style="color: #0000ff;">oracle@dhn-laptop:~$ ls /usr/lib | grep c++</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">libstdc++.so.6</span><br style="color: #0000ff;" />
<span style="color: #0000ff;">libstdc++.so.6.0.10</span><br />
发现有两个，而且主要还是使用的是<span style="color: #0000ff;">libstdc++.so.6.0.10</span>的，<span style="color: #0000ff;">libstdc++.so.6仅仅是一个到</span><span style="color: #0000ff;">libstdc++.so.6.0.10的链接文件，所以我们也可以这么作。</span>建立一个链接文件即可。<br />
<span style="color: #0000ff;">root@dhn-laptop:~# ln -s /usr/lib/libstdc++.so.6 /usr/lib/libstdc++.so.5</span><br />
<br />
然后重试，一切ok。<br />
<br />
以下是Oracle的 J2EE 应用程序已经配置完, 并且可用下面列出的 URL 来访问。<br />
iSQL*Plus URL:<br />
http://dhn-laptop:5560/isqlplus<br />
<br />
iSQL*Plus DBA URL:<br />
http://dhn-laptop:5560/isqlplus/dba<br />
<br />
Enterprise Manager 10g Database Control URL:<br />
http://dhn-laptop:1158/em
<img src ="http://www.blogjava.net/keweibo/aggbug/307781.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-12-30 16:09 <a href="http://www.blogjava.net/keweibo/articles/307781.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu 9.04安装oracle 10g(轉)</title><link>http://www.blogjava.net/keweibo/articles/307749.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Wed, 30 Dec 2009 05:48:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/307749.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/307749.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/307749.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/307749.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/307749.html</trackback:ping><description><![CDATA[<strong>ubuntu 9.04安装oracle 10g</strong><br />
<br />
按照这个文章，基本可以搞定<br />
[url=http://duecare.biz/webtech/oracle-10g-inst-on-ubuntu-serv.html]http://duecare.biz/webtech/oracle-10g-inst-on-ubuntu-serv.html[/url]<br />
为防止链接失效，复制一份过来：<br />
ORACLE 10g的安装主要参考了<br />
[url=http://wiki.ubuntu.org.cn/Oracle10g][color=#0000ff]Ubuntu Wiki[/color][/url]<br />
，我自己的一些记录如下： <br />
1、基本要求： <br />
我的VMWare下的Ubuntu Server 7.10，1G RAM，2G Swap，确认安装如下包： <br />
# apt-get install gcc make binutils lesstif2 libc6 libc6-dev rpm libmotif3 libaio libstdc++5<br />
//注意libc6-dev <br />
2、创建用户 <br />
安装Oracle需要在你机器上新建一个系统用户和三个组。 <br />
# addgroup oinstall <br />
# addgroup dba <br />
# addgroup nobody <br />
# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle <br />
# passwd oracle <br />
# usermod -g nobody nobody<br />
3、创建目录并设置权限 <br />
# mkdir -p /opt/oracle <br />
# mkdir /opt/oradata <br />
# chown -R oracle:oinstall /opt/ora* <br />
# chmod -R 775 /opt/ora*<br />
4、更改系统配置 <br />
在/etc/sysctl.conf中添加如下几行： <br />
kernel.shmall = 2097152 <br />
kernel.shmmax = 2147483648 <br />
kernel.shmmni = 4096 <br />
kernel.sem = 250 32000 100 128 <br />
fs.file-max = 65536 <br />
net.ipv4.ip_local_port_range = 1024 65000 <br />
运行下面命令以更新设置： <br />
# sysctl -p <br />
然後在/etc/security/limits.conf中添加下面几行： <br />
*&nbsp; &nbsp; soft&nbsp; &nbsp; nproc&nbsp; &nbsp; 2407 <br />
*&nbsp; &nbsp; hard&nbsp; &nbsp; nproc&nbsp; &nbsp; 16384 <br />
*&nbsp; &nbsp; soft&nbsp; &nbsp; nofile&nbsp; &nbsp;1024 <br />
*&nbsp; &nbsp; hard&nbsp; &nbsp; nofile&nbsp; &nbsp;65536 <br />
创建如下符号链接： <br />
# ln -s /usr/bin/awk /bin/awk <br />
# ln -s /usr/bin/rpm /bin/rpm <br />
# ln -s /usr/bin/basename /bin/basename <br />
安装ORACLE还需要创建如下几个链接： <br />
#mkdir /etc/rc.d <br />
# ln -s /etc/rc0.d /etc/rc.d/rc0.d <br />
# ln -s /etc/rc2.d /etc/rc.d/rc2.d <br />
# ln -s /etc/rc3.d /etc/rc.d/rc3.d <br />
# ln -s /etc/rc4.d /etc/rc.d/rc4.d <br />
# ln -s /etc/rc5.d /etc/rc.d/rc5.d <br />
# ln -s /etc/rc6.d /etc/rc.d/rc6.d <br />
# ln -s /etc/init.d /etc/rc.d/init.d<br />
在/etc/redhat-release中添加以下语句，以使安装程序认为我们正在一个RedHat的系统上安装： <br />
Red Hat Linux release 4.1<br />
4、配置ORACLE用户环境 <br />
以oracle用户登录，进入主目录，配置.profile文件，我的配置如下： <br />
export ORACLE_BASE=/opt/oracle <br />
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 <br />
export ORACLE_SID=shen <br />
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin <br />
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib <br />
export LC_CTYPE=en_US.UTF-8<br />
5、安装ORACLE <br />
选将ORACLE 10.2.0 Ftp到安装临时目录，我是放在/home/oracle/src/database下，配置相关权限，除runInstaller，我在安装时出现install/.oui文件权限的问题： <br />
chmod 755 runInstaller <br />
cd install <br />
chmod 755 unzip <br />
chmod 755 .oui<br />
配置XServer：由于Ubuntu
Server没有图形界面，因此需要配置外部XWindows，我很久以前就在使用的一个叫X-Win32的很小的程序，可以作XWin的，之前在
RHAS/Solaris上安装都没问题，结果这次用Ubuntu安装一直出现不了Java界面，折腾了很长时间，本想在Ubuntu
Server上安装Desktop的，但看包太大，于是放弃，从网上下了一个最新版本的Xmanager，结果成功安装。 <br />
export DISPLAY=10.0.0.9:0.0<br />
最新更新(08-01-27)：图形界面的原因不在X-Win32，而是Ubuntu要将图形输出到外部的XWin，自身必须有XWin的核心：<br />
$ sudo apt-get install x-window-system-core<br />
执行安装程序，安装过程非常顺利，甚至在wiki里提到的在执行root.sh时要配置的几个内容，我都没有配置，创建数据库成功。（我在RHAS4下也有很多警告的，在这里竟然一个都没有，很让我吃惊。） <br />
在执行root.sh时遇到点小麻烦，我的oracle帐户没有sudo权限，有sudo权限的又无法进入ORACLE_HOME，后来先用oracle
帐户进入到root.sh目录下，然后su成有sudo权限的帐户再sudo
./root.sh的。写这个备忘的时候才发现自己如此之笨，在哪个目录下sudo不是一样的嘛！！<br />
<br />
另，安装过程中会遇到这个问题，参考这里解决<br />
[url=http://www.oklinux.cn/html/sql/other/20090714/71878.html]http://www.oklinux.cn/html/sql/other/20090714/71878.html[/url]<br />
内容复制过来<br />
今天在<br />
[url=http://so.oklinux.cn/%20title=][color=#0000ff]Ubuntu[/color][/url]<br />
Server 9.04 上安装Oracle 10.2，安装到80%时出现all_no_orcl错误<br />
根据提示打开日志文件，发现如下错误：<br />
信息: Creating /opt/oracle/lib/liborasdkbase.so.10.2<br />
信息: gcc:<br />
信息: /usr/lib/libstdc .so.5：没有该文件或目录<br />
信息:<br />
信息: /opt/oracle/bin/genorasdksh: Failed to link liborasdkbase.so.10.2<br />
信息: make: *** [liborasdkbase] 错误 1<br />
原来是libstdc 包的错误，经检查，原来应该安装libstdc 5的包，但是系统在安装其他程序时<br />
已经安装libstdc 6的包，导致libstdc 5未安装<br />
那么如何解决呢,经多方查找，可以使用鱼目混珠的方式，如下：<br />
打开另外一个终端执行以下命令<br />
cd /usr/lib<br />
ln -s libstdc .so.6 libstdc .so.5<br />
然后返回Oracle安装界面，重试 <br />
<br />
<br />
[b]本文来自ChinaUnix博客，如果查看原文请点：[/b][url]http://blog.chinaunix.net/u3/93140/showart_2007242.html[/url]
<img src ="http://www.blogjava.net/keweibo/aggbug/307749.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-12-30 13:48 <a href="http://www.blogjava.net/keweibo/articles/307749.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle 層次查詢</title><link>http://www.blogjava.net/keweibo/articles/306484.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 18 Dec 2009 02:12:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/306484.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/306484.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/306484.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/306484.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/306484.html</trackback:ping><description><![CDATA[select distinct c.NUMTREENODE,c.NUMNODE,c.STRFUNCTION,c.STRURL,c.STRTYPE from BARCODE.ECSM_SFIS_SYS_FUNC c<br />
&nbsp;&nbsp;&nbsp; <strong><span style="color: red;">start with</span></strong> c.NUMTREENODE in (<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT sf.NUMTREENODE <br />
&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FROM ECSM_SFIS_SYS_ROLE_FUNC rf, ECSM_SFIS_SYS_ROLE sr, ECSM_SFIS_SYS_FUNC sf, ECSM_SFIS_SYS_EMP se, ECSM_SFIS_SYS_ROLE_EMP re <br />
&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE rf.ROLE_INDEX = sr.NUMINDEX and rf.FUNC_INDEX= sf.NUMINDEX and re.EMP_INDEX = se.NUMINDEX <br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; and re.ROLE_INDEX = sr.NUMINDEX and sf.STRTYPE ='Y' and (se.STRUSERNAME = 'guest' or se.STRUSERNAME = #username# ) <br />
&nbsp;&nbsp;&nbsp; )<br />
<strong>&nbsp;&nbsp;&nbsp; connect by prior c.numnode = c.numtreenode</strong><br />
<br />
CREATE TABLE BARCODE.ECSM_SFIS_SYS_FUNC<br />
(<br />
&nbsp; NUMINDEX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INTEGER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL,<br />
&nbsp; NUMTREENODE&nbsp;&nbsp;&nbsp; NUMBER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL,<br />
&nbsp; NUMNODE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NUMBER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL,<br />
&nbsp; STRFUNCTION&nbsp;&nbsp;&nbsp; VARCHAR2(32 BYTE)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL,<br />
&nbsp; STRCREATEUSER&nbsp; VARCHAR2(16 BYTE)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL,<br />
&nbsp; DTCREATE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DATE,<br />
&nbsp; STRTITLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR2(64 BYTE),<br />
&nbsp; STRTARGET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR2(16 BYTE),<br />
&nbsp; STRURL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR2(128 BYTE),<br />
&nbsp; STRTYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CHAR(1 BYTE)<br />
)<br />
<br />
<img src ="http://www.blogjava.net/keweibo/aggbug/306484.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-12-18 10:12 <a href="http://www.blogjava.net/keweibo/articles/306484.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle nvl(), cont(), decode()函數, case表達式結合使用的一條SQL語句</title><link>http://www.blogjava.net/keweibo/articles/300184.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Thu, 29 Oct 2009 07:22:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/300184.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/300184.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/300184.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/300184.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/300184.html</trackback:ping><description><![CDATA[SELECT&nbsp;&nbsp; nvl(i.tools_model, 'ALL'), <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COUNT(decode(r.maintain_no, 'MAINTAIN', 'MAINTAIN','REPAIR', 'REPAIR', null)) as "維修總次數",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COUNT(decode(r.maintain_no, 'MAINTAIN', 'MAINTAIN', null)) as "正常維修次數",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COUNT(decode(r.maintain_no, 'REPAIR', 'REPAIR', null)) as "返修次數",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case COUNT(decode(r.maintain_no, 'MAINTAIN', 'MAINTAIN','REPAIR', 'REPAIR', null))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; when 0 then 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COUNT(decode(r.maintain_no, 'REPAIR', 'REPAIR', null))/COUNT(decode(r.maintain_no, 'MAINTAIN', 'MAINTAIN','MAINTAIN', 'MAINTAIN', null))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end as "返修率"<br />
&nbsp;&nbsp;&nbsp; FROM smtuser.feeder_maintain_recordn r, smtuser.feeder_tools_info i<br />
&nbsp;&nbsp; WHERE r.tools_no(+) = i.tools_no<br />
&nbsp;&nbsp;&nbsp;&nbsp; AND TO_CHAR (r.repair_date(+), 'YYYY/MM/DD') = TO_CHAR (SYSDATE, 'YYYY/MM/DD')<br />
GROUP BY rollup(i.tools_model)<br />
<img src ="http://www.blogjava.net/keweibo/aggbug/300184.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-10-29 15:22 <a href="http://www.blogjava.net/keweibo/articles/300184.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>慎用Oracle的not in (轉)</title><link>http://www.blogjava.net/keweibo/articles/299053.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 20 Oct 2009 08:05:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/299053.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/299053.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/299053.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/299053.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/299053.html</trackback:ping><description><![CDATA[帮财务人员处理数据，一个是ERP系统中的账面数据，一个是税务局给的官方数据，一张EXCEL表，想找出两边不匹配的数据。
<p>&nbsp;&nbsp;&nbsp; 据说EXCEL2007版本已经提供了这种比对的功能，但无奈数据量太大，操作起来巨慢如牛，而WPS2009似乎还没这个功能，于是导入数据库中新建一个表<a class="channel_keylink" href="http://www.storworld.com/" target="_blank">存储</a>这些数据来比对。</p>
<p>&nbsp;&nbsp;&nbsp; 开始写了个SQL来查询税务有而ERP系统中没有的数据：</p>
<p>&nbsp;&nbsp;&nbsp; select * from tab_excel where taxcode not in</p>
<p>&nbsp;&nbsp;&nbsp; (select erpcode from tab_excel)</p>
<p>&nbsp;&nbsp;&nbsp; 正常，然后反过来查ERP中存在而税务系统中不存在的数据：</p>
<p>&nbsp;&nbsp;&nbsp; select * from tab_excel where erpcode not in</p>
<p>&nbsp;&nbsp;&nbsp; (select taxcode from tab_excel)</p>
<p>&nbsp;&nbsp;&nbsp; 返回0条数据，很奇怪，然后马上想到了是null的问题，taxcode必然存在值为null的记录，oracle中和null比较的返回值是unkown，所以才无法匹配。</p>
<p>&nbsp;&nbsp;&nbsp; 于是修改SQL语句如下：</p>
<p>&nbsp;&nbsp;&nbsp; select * from tab_excel tout where not exists</p>
<p>&nbsp;&nbsp;&nbsp; (select 1 from tab_excel where taxcode=tout.erpcode)</p>
<p>&nbsp;&nbsp;&nbsp; 结果正常。</p>
<p>&nbsp;&nbsp;&nbsp; not in (...) 括号中的返回值不能存在null值，是<a class="channel_keylink" href="http://oracle.chinaitlab.com/" target="_blank">Oracle</a> SQL开发的一条铁律，如果不能确定返回结果一定无null值，还是改写为not esists吧。而且not in效率低下，一般不能用到索引，生产环境的程序最好不要使用。</p>
<img src ="http://www.blogjava.net/keweibo/aggbug/299053.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-10-20 16:05 <a href="http://www.blogjava.net/keweibo/articles/299053.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle使用Decode函數統計次數</title><link>http://www.blogjava.net/keweibo/articles/298563.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 16 Oct 2009 06:03:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/298563.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/298563.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/298563.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/298563.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/298563.html</trackback:ping><description><![CDATA[select c.LINE, c.SITE, c.REELNO, max(c.ACTIONDATE) dt, <br />
count(*) "總次數", <br />
count(decode(c.status,0,0,null)) "通過次數", <br />
count(decode(c.status,1,1,null)) "異常次數" <br />
from tbl_smt_check c, tbl_smt_seq s <br />
&nbsp;where c.SEQ = s.SEQ and c.STATUS in (0, 1)<br />
<br />
其中,STATUS數據列的值為 0 或者 1 <br />
<img src ="http://www.blogjava.net/keweibo/aggbug/298563.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-10-16 14:03 <a href="http://www.blogjava.net/keweibo/articles/298563.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>oracle 使用多表插入數據</title><link>http://www.blogjava.net/keweibo/articles/294808.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Sat, 12 Sep 2009 01:24:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/294808.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/294808.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/294808.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/294808.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/294808.html</trackback:ping><description><![CDATA[从oracle9i开始引入了insert all关键字支持将某张表的数据同时插入多张表单。语法如下：
<div>Insert all Insert_into_clause [value_clause] subquery;</div>
<div>Insert conditional_insert_clause subquery;</div>
<div>如上所示，insert_into_clause用于指定insert子句；value clause用于指定值子句；subquery用于指定提供数据的子查询；condition_insert_clause用于指定insert条件子句。</div>
<div>当使用all操作符执行多表插入时，在每个条件子句上都要执行into子句后的子查询，并且条件中使用的列必须在插入和子查询的结果集中：</div>
<br />
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;">--</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;">使用</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;">all</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;">关键字执行多表插入操作</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">insert</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">all</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> birthday &gt; </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'01-1</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">月</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">-08'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate1</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> birthday &lt; </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'01-1</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">月</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">-08'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate2</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">name</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> = </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'zhangsan'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate1</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">name</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> = </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'lisi'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate2</span></div>
<div><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">select</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> * </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">from</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate;</span></div>
<div>在上述操作语句中，如果原表tdate中存在既满足<span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">birthday &gt; '01-1</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">月</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">-08'</span><span style="font-size: 10pt;">又满足</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">name = 'zhangsan'</span><span style="font-size: 10pt;">的数据，那么将执行两次插入。而使用</span><span style="font-size: 10pt;">first</span><span style="font-size: 10pt;">关键字就可以避免这个问题。使用</span><span style="font-size: 10pt;">first</span><span style="font-size: 10pt;">关键字时，如果有记录已经满足先前条件，并且已经被插入到某个表单中（未必非要是同一个表），那么该行数据在后续插入中将不会被再次使用。也就是说使用</span><span style="font-size: 10pt;">first</span><span style="font-size: 10pt;">关键字，原表每行数据按照执行顺序只会被插入一次。</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">insert</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">first</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> birthday &gt; </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'01-1</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">月</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">-08'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate1</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> birthday &lt; </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'01-1</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">月</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">-08'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate2</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">name</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> = </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'zhangsan'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate1</span></div>
<div align="left"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">when</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">name</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> = </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue;">'lisi'</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">then</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">into</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate2</span></div>
<div><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">select</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> * </span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: teal;">from</span><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: navy;"> tdate;</span></div>
<img src ="http://www.blogjava.net/keweibo/aggbug/294808.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-09-12 09:24 <a href="http://www.blogjava.net/keweibo/articles/294808.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>rowconcat 函數</title><link>http://www.blogjava.net/keweibo/articles/294241.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 08 Sep 2009 00:12:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/294241.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/294241.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/294241.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/294241.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/294241.html</trackback:ping><description><![CDATA[CREATE OR REPLACE FUNCTION SMTUSER.rowconcat(q in VARCHAR2) RETURN VARCHAR2 IS<br />
&nbsp;&nbsp;&nbsp;&nbsp; ret&nbsp; VARCHAR2(4000);<br />
&nbsp;&nbsp;&nbsp;&nbsp; hold VARCHAR2(4000);<br />
&nbsp;&nbsp;&nbsp;&nbsp; cur&nbsp; sys_refcursor;<br />
&nbsp;&nbsp; BEGIN<br />
&nbsp;&nbsp;&nbsp;&nbsp; OPEN cur FOR q;<br />
&nbsp;&nbsp;&nbsp;&nbsp; LOOP<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FETCH cur INTO hold;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXIT WHEN cur%NOTFOUND;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IF ret IS NULL THEN<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret := hold;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ELSE<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret := ret || ',' || hold;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; END IF;<br />
&nbsp;&nbsp;&nbsp; END LOOP;<br />
&nbsp;&nbsp;&nbsp; RETURN ret;<br />
&nbsp; END;<br />
/<br />
<img src ="http://www.blogjava.net/keweibo/aggbug/294241.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-09-08 08:12 <a href="http://www.blogjava.net/keweibo/articles/294241.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>not exists </title><link>http://www.blogjava.net/keweibo/articles/294213.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Mon, 07 Sep 2009 12:15:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/294213.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/294213.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/294213.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/294213.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/294213.html</trackback:ping><description><![CDATA[Bob&#8216;s SQL:<br />
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">SELECT</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
NUMINDEX</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRITEMNO</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">NUMTYPE</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRMODELNAME</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">TO_CHAR</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">DTUPDATE</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">'YYYY/MM/DD
HH24:MI:SS'</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">)AS</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> DTUPDATE
<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">FROM</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="olive" face="Courier" size="2"><span style="font-size: 10pt; color: olive; font-family: Courier;" lang="EN-US">ECSM_ITEMNO_INFORMATION</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
e<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp;&nbsp;&nbsp;
&nbsp;</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
e</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRITEMNO
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">not</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">in</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(select</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
i</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRITEMNO
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="olive" face="Courier" size="2"><span style="font-size: 10pt; color: olive; font-family: Courier;" lang="EN-US">TBL_SMT_ITEMNO</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
i</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">)</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">and</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
e</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">DTUPDATE
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">not</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">in</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(select</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
i</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">CREATEDATE
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="olive" face="Courier" size="2"><span style="font-size: 10pt; color: olive; font-family: Courier;" lang="EN-US">TBL_SMT_ITEMNO</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
i</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">)</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">order</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">by</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> DTUPDATE
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">desc<o:p></o:p></span></font></p>
<br />
<br />
Wallace's SQL:<br />
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">SELECT</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
NUMINDEX</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRITEMNO</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">NUMTYPE</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRMODELNAME</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">TO_CHAR</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">DTUPDATE</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">'YYYY/MM/DD
HH24:MI:SS'</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">)</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">AS</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> DTUPDATE
<o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">FROM</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
ECSM_ITEMNO_INFORMATION e<o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">not</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">exists</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">select</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="maroon" face="Courier" size="2"><span style="font-size: 10pt; color: maroon; font-family: Courier;" lang="EN-US">1</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> TBL_SMT_ITEMNO i
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
i</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRITEMNO</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">=</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">e</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">STRITEMNO
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">and</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
i</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">CREATEDATE</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">=</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">e</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">.</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">DTUPDATE
</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">)</span></font></p>
<br />
<img src ="http://www.blogjava.net/keweibo/aggbug/294213.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-09-07 20:15 <a href="http://www.blogjava.net/keweibo/articles/294213.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>多行一列轉成一行多列的SQL語句</title><link>http://www.blogjava.net/keweibo/articles/294212.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Mon, 07 Sep 2009 12:12:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/294212.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/294212.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/294212.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/294212.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/294212.html</trackback:ping><description><![CDATA[<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">Bob's SQL:<br />
</span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">select</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">CONTENT</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="red" face="新細明體" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: 新細明體;">料號</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="olive" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: olive; font-family: Courier;" lang="EN-US">T_DISENABLE_MATERIAL_INFO</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
ITEM</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">'M'</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">and</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
DOCUMENT_ID</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="maroon" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: maroon; font-family: Courier;" lang="EN-US">4329</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">select</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">CONTENT</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"DC"</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="olive" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: olive; font-family: Courier;" lang="EN-US">T_DISENABLE_MATERIAL_INFO</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
ITEM</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">'D'</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">and</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
DOCUMENT_ID</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="maroon" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: maroon; font-family: Courier;" lang="EN-US">4329</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><u><font color="blue" face="Courier New" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: 'Courier New';" lang="EN-US">select</span></font></u><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">CONTENT</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"LOTNO"</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="olive" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: olive; font-family: Courier;" lang="EN-US">T_DISENABLE_MATERIAL_INFO</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
ITEM</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">'C'</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">and</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
DOCUMENT_ID</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="maroon" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: maroon; font-family: Courier;" lang="EN-US">4329</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">select</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">CONTENT</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="red" face="新細明體" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: 新細明體;">廠商名稱</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="olive" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: olive; font-family: Courier;" lang="EN-US">T_DISENABLE_MATERIAL_INFO</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
ITEM</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">'V'</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">and</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
DOCUMENT_ID</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="maroon" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: maroon; font-family: Courier;" lang="EN-US">4329</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">select</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">CONTENT</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="red" face="新細明體" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: 新細明體;">廠商代碼</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="olive" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: olive; font-family: Courier;" lang="EN-US">T_DISENABLE_MATERIAL_INFO</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
ITEM</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="red" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: red; font-family: Courier;" lang="EN-US">'N'</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">and</span></font><font color="black" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-family: Courier;" lang="EN-US">
DOCUMENT_ID</span></font><font color="blue" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: blue; font-family: Courier;" lang="EN-US">=</span></font><font color="maroon" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: maroon; font-family: Courier;" lang="EN-US">4329</span></font></p>
<p><font color="maroon" face="Courier" size="2"><span style="background: white none repeat scroll 0% 0%; font-size: 10pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: maroon; font-family: Courier;" lang="EN-US"><br />
</span></font></p>
<p>&nbsp;</p>
<p><font color="maroon" face="Courier" size="2"><span style="font-size: 10pt; color: maroon; font-family: Courier;" lang="EN-US"><o:p>Wallace's SQL</o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">select</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
max</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">decode</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">item</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">'M'</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">content</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">''</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">))</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="red" face="SimSun" size="2"><span style="font-size: 10pt; color: red; font-family: SimSun;" lang="ZH-CN">料號</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp; &nbsp;&nbsp;
max</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">decode</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">item</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">'D'</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">content</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">''</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">))</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
DC</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp; &nbsp;&nbsp;
max</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">decode</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">item</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">'C'</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">content</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">''</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">))</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
LOTNO</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp; &nbsp;&nbsp;
max</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">decode</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">item</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">'V'</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">content</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">''</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">))</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="red" face="SimSun" size="2"><span style="font-size: 10pt; color: red; font-family: SimSun;" lang="ZH-CN">廠商名稱</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"><o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">&nbsp; &nbsp;&nbsp;
max</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">decode</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">(</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">item</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">'N'</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">content</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">,</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">''</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">))</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="red" face="SimSun" size="2"><span style="font-size: 10pt; color: red; font-family: SimSun;" lang="ZH-CN">廠商代碼</span></font><font color="red" face="Courier" size="2"><span style="font-size: 10pt; color: red; font-family: Courier;" lang="EN-US">"</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US"> </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">from</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
T_DISENABLE_MATERIAL_INFO </span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">where</span></font><font color="black" face="Courier" size="2"><span style="font-size: 10pt; color: black; font-family: Courier;" lang="EN-US">
DOCUMENT_ID</span></font><font color="#0000f0" face="Courier" size="2"><span style="font-size: 10pt; color: #0000f0; font-family: Courier;" lang="EN-US">=</span></font><font color="maroon" face="Courier" size="2"><span style="font-size: 10pt; color: maroon; font-family: Courier;" lang="EN-US">4329</span></font></p>
<img src ="http://www.blogjava.net/keweibo/aggbug/294212.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-09-07 20:12 <a href="http://www.blogjava.net/keweibo/articles/294212.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java调用Oracle函数</title><link>http://www.blogjava.net/keweibo/articles/270153.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 12 May 2009 02:27:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/270153.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/270153.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/270153.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/270153.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/270153.html</trackback:ping><description><![CDATA[<div class="rightmenu">&nbsp;</div>
<div style="overflow: hidden" id="body_l" class="rightbox">
<h2>调用无入参的函数</h2>
<h3>函数定义</h3>
<p><font face="Verdana">CREATE OR REPLACE Function f_getstring Return Varchar2 Is<br />
Begin<br />
&nbsp;Return ''String value'';<br />
End f_getstring;</font></p>
<h3>调用函数的Java片断</h3>
<p><font face="Verdana">&nbsp;&nbsp;&nbsp;CallableStatement cstmt = con.prepareCall("{?=call f_getstring}");<br />
&nbsp;&nbsp;&nbsp;cstmt.registerOutParameter(1, Types.VARCHAR);<br />
&nbsp;&nbsp;&nbsp;cstmt.execute();<br />
&nbsp;&nbsp;&nbsp;String strValue = cstmt.getString(1);<br />
&nbsp;&nbsp;&nbsp;System.out.println("The return value is:" + strValue);<br />
&nbsp;&nbsp;&nbsp;cstmt.close();</font></p>
<h2>调用有一个入参，一个输出参数以及一个字符串返回值的函数</h2>
<h3>函数定义</h3>
<p><font face="Verdana">CREATE OR REPLACE Function f_Getinfo(Id Integer, Age Out Integer) Return Varchar2 Is<br />
Begin<br />
&nbsp;Age := 10;<br />
&nbsp;Return ''The age is:'' || Id;<br />
End f_Getinfo;</font></p>
<h3>调用函数的Java代码片断</h3>
<p><font face="Verdana">&nbsp;&nbsp;&nbsp;CallableStatement cstmt = con<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.prepareCall("{?=call f_getinfo(?,?)}");<br />
&nbsp;&nbsp;&nbsp;cstmt.registerOutParameter(1, Types.VARCHAR);<br />
&nbsp;&nbsp;&nbsp;cstmt.setInt(2, 11);<br />
&nbsp;&nbsp;&nbsp;cstmt.registerOutParameter(3, Types.INTEGER);<br />
&nbsp;&nbsp;&nbsp;cstmt.execute();<br />
&nbsp;&nbsp;&nbsp;String strValue = cstmt.getString(1);<br />
&nbsp;&nbsp;&nbsp;int age = cstmt.getInt(3);<br />
&nbsp;&nbsp;&nbsp;System.out.println("The return value is:" + strValue<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ " and age is:" + age);<br />
&nbsp;&nbsp;&nbsp;cstmt.close();</font></p>
</div>
<img src ="http://www.blogjava.net/keweibo/aggbug/270153.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-05-12 10:27 <a href="http://www.blogjava.net/keweibo/articles/270153.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转贴：Oracle中UTL_FILE包的用法</title><link>http://www.blogjava.net/keweibo/articles/254308.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Wed, 11 Feb 2009 12:26:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/254308.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/254308.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/254308.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/254308.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/254308.html</trackback:ping><description><![CDATA[<p>最近接触了Oracle的读写文件操作，于是使用到UTL_FILE包，再网上查找到一些有用的信息，在此和大家分享一下。 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 以下翻译来自《Oracle Built-in Packages》的第六章，只翻译了部分，想了解的更详细，请参考原文。<a href="http://www.oreilly.com/catalog/oraclebip/chapter/ch06.html">http://www.oreilly.com/catalog/oraclebip/chapter/ch06.html</a></p>
<p>FOPEN <br />
IS_OPEN <br />
GET_LINE <br />
PUT <br />
NEW_LINE <br />
PUT_LINE <br />
PUTF <br />
FFLUSH <br />
FCLOSE <br />
FCLOSE_ALL <br />
<br />
<strong>UTL_FILE.FOPEN</strong> 用法<br />
FOPEN会打开指定文件并返回一个文件句柄用于操作文件。<br />
所有PL/SQL版本:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Oracle 8.0版及以上:<br />
FUNCTION UTL_FILE.FOPEN (&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FUNCTION UTL_FILE.FOPEN (<br />
&nbsp;&nbsp;&nbsp; location&nbsp;&nbsp;&nbsp;&nbsp; IN VARCHAR2,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location&nbsp;&nbsp;&nbsp;&nbsp; IN VARCHAR2,<br />
&nbsp;&nbsp;&nbsp; filename&nbsp;&nbsp;&nbsp;&nbsp; IN VARCHAR2,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filename&nbsp;&nbsp;&nbsp;&nbsp; IN VARCHAR2,<br />
&nbsp;&nbsp;&nbsp; open_mode&nbsp;&nbsp;&nbsp; IN VARCHAR2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open_mode&nbsp;&nbsp;&nbsp; IN VARCHAR2,<br />
RETURN file_type;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_linesize IN BINARY_INTEGER)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RETURN file_type;</p>
<p>参数<br />
<br />
location<br />
文件地址<br />
<br />
filename<br />
文件名<br />
<br />
openmode<br />
打开文件的模式（参见下面说明）<br />
<br />
max_linesize<br />
文件每行最大的字符数，包括换行符。最小为1，最大为32767<br />
<br />
3种文件打开模式：<br />
R 只读模式。一般配合UTL_FILE的GET_LINE来读文件。<br />
W 写（替换）模式。文件的所有行会被删除。PUT, PUT_LINE, NEW_LINE, PUTF和FFLUSH都可使用<br />
A 写（附加）模式。原文件的所有行会被保留。在最末尾行附加新行。PUT, PUT_LINE, NEW_LINE, PUTF和FFLUSH都可使用</p>
<p>打开文件时注意以下几点：<br />
文件路径和文件名合起来必须表示操作系统中一个合法的文件。<br />
文件路径必须存在并可访问；FOPEN并不会新建一个文件夹。<br />
如果你想打开文件进行读操作，文件必须存在；如果你想打开文件进行写操作，文件不存在时，会新建一个文件。<br />
如果你想打开文件进行附加操作，文件必须存在。A模式不同于W模式。文件不存在时，会抛出INVALID_OPERATION异常。</p>
<p>FOPEN 会抛出以下异常<br />
UTL_FILE.INVALID_MODE<br />
UTL_FILE.INVALID_OPERATION<br />
UTL_FILE.INVALID_PATH<br />
UTL_FILE.INVALID_MAXLINESIZE</p>
<p><strong>UTL_FILE.IS_OPEN</strong>用法<br />
如果文件句柄指定的文件已打开，返回TRUE，否则FALSE</p>
<p>FUNCTION UTL_FILE.IS_OPEN (file IN UTL_FILE.FILE_TYPE) RETURN BOOLEAN;</p>
<p>UTL_FILE只提供一个方法去读取数据：GET_LINE</p>
<p><strong>UTL_FILE.GET_LINE</strong>用法<br />
读取指定文件的一行到提供的缓存。<br />
PROCEDURE UTL_FILE.GET_LINE <br />
&nbsp;&nbsp; (file IN UTL_FILE.FILE_TYPE, <br />
&nbsp;&nbsp;&nbsp; buffer OUT VARCHAR2);</p>
<p>file<br />
由FOPEN返回的文件句柄<br />
<br />
buffer<br />
读取的一行数据的存放缓存</p>
<p>buffer必须足够大。否则，会抛出VALUE_ERROR 异常。行终止符不会被传进buffer。</p>
<p>异常<br />
NO_DATA_FOUND <br />
VALUE_ERROR <br />
UTL_FILE.INVALID_FILEHANDLE<br />
UTL_FILE.INVALID_OPERATION<br />
UTL_FILE.READ_ERROR</p>
<p><br />
<strong>UTL_FILE.PUT</strong>用法<br />
在当前行输出数据<br />
PROCEDURE UTL_FILE.PUT <br />
&nbsp;&nbsp;&nbsp; (file IN UTL_FILE.FILE_TYPE, <br />
&nbsp;&nbsp;&nbsp; buffer OUT VARCHAR2);<br />
file<br />
由FOPEN返回的文件句柄<br />
buffer<br />
包含要写入文件的数据缓存；Oracle8.0.3及以上最大允许32kB，早期版本只有1023B</p>
<p>UTL_FILE.PUT输出数据时不会附加行终止符。</p>
<p>UTL_FILE.PUT会产生以下异常<br />
UTL_FILE.INVALID_FILEHANDLE<br />
UTL_FILE.INVALID_OPERATION<br />
UTL_FILE.WRITE_ERROR</p>
<p><strong>UTL_FILE.NEW_LINE<br />
</strong>在当前位置输出新行或行终止符，必须使用NEW_LINE来结束当前行，或者使用PUT_LINE输出带有行终止符的完整行数据。</p>
<p>PROCEDURE UTL_FILE.NEW_LINE <br />
&nbsp;&nbsp; (file IN UTL_FILE.FILE_TYPE, <br />
&nbsp;&nbsp;&nbsp; lines IN NATURAL := 1); <br />
file<br />
由FOPEN返回的文件句柄<br />
lines<br />
要插入的行数</p>
<p>如果不指定lines参数，NEW_LINE会使用默认值1，在当前行尾换行。如果要插入一个空白行，可以使用以下语句：<br />
UTL_FILE.NEW_LINE (my_file, 2);<br />
如果lines参数为0或负数，什么都不会写入文件。</p>
<p>NEW_LINE会产生以下异常<br />
VALUE_ERROR<br />
UTL_FILE.INVALID_FILEHANDLE<br />
UTL_FILE.INVALID_OPERATION<br />
UTL_FILE.WRITE_ERROR<br />
例子<br />
如果要在UTL_FILE.PUT后立刻换行，可以如下例所示：<br />
PROCEDURE add_line (file_in IN UTL_FILE.FILE_TYPE, line_in IN VARCHAR2)<br />
IS<br />
BEGIN<br />
&nbsp;&nbsp; UTL_FILE.PUT (file_in, line_in);<br />
&nbsp;&nbsp; UTL_FILE.NEW_LINE (file_in);<br />
END;</p>
<p><br />
<strong>UTL_FILE.PUT_LINE</strong> <br />
输出一个字符串以及一个与系统有关的行终止符<br />
PROCEDURE UTL_FILE.PUT_LINE <br />
&nbsp;&nbsp;&nbsp; (file IN UTL_FILE.FILE_TYPE, <br />
&nbsp;&nbsp;&nbsp; buffer IN VARCHAR2);<br />
file<br />
由FOPEN返回的文件句柄<br />
buffer<br />
包含要写入文件的数据缓存；Oracle8.0.3及以上最大允许32kB，早期版本只有1023B<br />
在调用UTL_FILE.PUT_LINE前，必须先打开文件。<br />
UTL_FILE.PUT_LINE会产生以下异常<br />
UTL_FILE.INVALID_FILEHANDLE<br />
UTL_FILE.INVALID_OPERATION<br />
UTL_FILE.WRITE_ERROR</p>
<p>例子<br />
这里利用UTL_FILE.PUT_LINE从表emp读取数据到文件：<br />
PROCEDURE emp2file <br />
IS<br />
&nbsp;&nbsp; fileID UTL_FILE.FILE_TYPE;<br />
BEGIN<br />
&nbsp;&nbsp; fileID := UTL_FILE.FOPEN ('/tmp', 'emp.dat', 'W');<br />
<br />
&nbsp;&nbsp; /* Quick and dirty construction here! */<br />
&nbsp;&nbsp; FOR emprec IN (SELECT * FROM emp)<br />
&nbsp;&nbsp; LOOP<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UTL_FILE.PUT_LINE <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (TO_CHAR (emprec.empno) || ',' ||<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; emprec.ename || ',' ||<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TO_CHAR (emprec.deptno));<br />
&nbsp;&nbsp; END LOOP;<br />
<br />
&nbsp;&nbsp; UTL_FILE.FCLOSE (fileID);<br />
END;<br />
PUT_LINE相当于PUT后加上NEW_LINE；也相当于PUTF的格式串"%s\n"。</p>
<p><strong>UTL_FILE.PUTF<br />
</strong>以一个模版样式输出至多5个字符串，类似C中的printf</p>
<p>PROCEDURE UTL_FILE.PUTF<br />
&nbsp;&nbsp;&nbsp; (file IN FILE_TYPE<br />
&nbsp;&nbsp;&nbsp; ,format IN VARCHAR2<br />
&nbsp;&nbsp;&nbsp; ,arg1 IN VARCHAR2 DEFAULT NULL<br />
&nbsp;&nbsp;&nbsp; ,arg2 IN VARCHAR2 DEFAULT NULL<br />
&nbsp;&nbsp;&nbsp; ,arg3 IN VARCHAR2 DEFAULT NULL<br />
&nbsp;&nbsp;&nbsp; ,arg4 IN VARCHAR2 DEFAULT NULL<br />
&nbsp;&nbsp;&nbsp; ,arg5 IN VARCHAR2 DEFAULT NULL);<br />
file<br />
由FOPEN返回的文件句柄<br />
format<br />
决定格式的格式串<br />
argN<br />
可选的5个参数，最多5个</p>
<p>格式串可使用以下样式<br />
%s<br />
在格式串中可以使用最多5个%s，与后面的5个参数一一对应<br />
\n<br />
换行符。在格式串中没有个数限制<br />
%s会被后面的参数依次填充，如果没有足够的参数，%s会被忽视，不被写入文件</p>
<p>UTL_FILE.PUTF会产生以下异常<br />
UTL_FILE.INVALID_FILEHANDLE<br />
UTL_FILE.INVALID_OPERATION<br />
UTL_FILE.WRITE_ERROR</p>
<p><strong>UTL_FILE.FFLUSH<br />
</strong>确保所有数据写入文件。<br />
PROCEDURE UTL_FILE.FFLUSH (file IN UTL_FILE.FILE_TYPE);<br />
file<br />
由FOPEN返回的文件句柄</p>
<p>操作系统可能会缓存数据来提高性能。因此可能调用put后，打开文件却看不到写入的数据。在关闭文件前要读取数据的话可以使用UTL_FILE.FFLUSH。<br />
典型的使用方法包括分析执行进度和调试纪录。<br />
UTL_FILE.FFLUSH会产生以下异常<br />
UTL_FILE.INVALID_FILEHANDLE<br />
UTL_FILE.INVALID_OPERATION<br />
UTL_FILE.WRITE_ERROR</p>
<p><strong>UTL_FILE.FCLOSE</strong> <br />
关闭文件<br />
PROCEDURE UTL_FILE.FCLOSE (file IN OUT FILE_TYPE);<br />
file<br />
由FOPEN返回的文件句柄</p>
<p>注意file是一个IN OUT参数，因为在关闭文件后会设置为NULL<br />
当试图关闭文件时有缓存数据未写入文件，会抛出WRITE_ERROR异常</p>
<p>UTL_FILE.FCLOSE会产生以下异常<br />
UTL_FILE.INVALID_FILEHANDLE<br />
UTL_FILE.WRITE_ERROR</p>
<p><strong>UTL_FILE.FCLOSE_ALL</strong> <br />
关闭所有已打开的文件<br />
PROCEDURE UTL_FILE.FCLOSE_ALL;</p>
<p>在结束程序时要确保所有打开的文件已关闭，可使用FCLOSE_ALL<br />
也可以在EXCEPTION使用，当异常退出时，文件也会被关闭。<br />
EXCEPTION<br />
&nbsp;&nbsp; WHEN OTHERS<br />
&nbsp;&nbsp; <br />
THEN<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UTL_FILE.FCLOSE_ALL;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ... other clean up activities ...<br />
END;</p>
<p>注意：当使用FCLOSE_ALL关闭所有文件时，文件句柄并不会标记为NULL，使用IS_OPEN会返回TRUE。但是，那些关闭的文件不能执行读写操作（除非你再次打开文件）。<br />
UTL_FILE.FCLOSE_ALL会产生以下异常<br />
UTL_FILE.WRITE_ERROR</p>
<img src ="http://www.blogjava.net/keweibo/aggbug/254308.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2009-02-11 20:26 <a href="http://www.blogjava.net/keweibo/articles/254308.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL Migration Toolkit</title><link>http://www.blogjava.net/keweibo/articles/175805.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Wed, 16 Jan 2008 15:52:00 GMT</pubDate><guid>http://www.blogjava.net/keweibo/articles/175805.html</guid><wfw:comment>http://www.blogjava.net/keweibo/comments/175805.html</wfw:comment><comments>http://www.blogjava.net/keweibo/articles/175805.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/keweibo/comments/commentRss/175805.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/keweibo/services/trackbacks/175805.html</trackback:ping><description><![CDATA[MYSQL与其它数据库之间的转换工具<br />
MySQL Migration Toolkit<br />
<br />
http://www.mysql.com/products/tools/migration-toolkit/<br />
相关视频教程
<img src ="http://www.blogjava.net/keweibo/aggbug/175805.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/keweibo/" target="_blank">Ke</a> 2008-01-16 23:52 <a href="http://www.blogjava.net/keweibo/articles/175805.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>