<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1529398903068091023</id><updated>2024-09-01T18:00:32.407+08:00</updated><category term="Oracle"/><category term="ASP.NET"/><category term="Group By"/><category term="LINQ"/><category term="Tool"/><category term="PL/SQL"/><category term="Analytic Functions"/><category term="Date"/><category term="Join"/><category term="Mod"/><category term="NVL"/><category term="Not"/><category term="Rollup"/><category term="To_Char"/><category term="Update"/><category term="coalesce"/><title type='text'>皮尼網前走</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-8393243614471131563</id><published>2017-03-06T19:52:00.002+08:00</published><updated>2017-03-06T19:52:51.954+08:00</updated><title type='text'>[Line Backup] Line 對話紀錄免Root無痛轉移 v7.1.1</title><content type='html'>參考了 電腦王阿達分享的&lt;a href=&quot;https://www.kocpc.com.tw/archives/2441&quot; target=&quot;_blank&quot;&gt;&amp;nbsp;[Android]LINE推出最新功能，讓您備份/還原聊天紀錄對話訊息&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
此版本在我手機(Device:HTC M9+ Line v7.1.1)並不work&lt;br /&gt;
&lt;br /&gt;
於是參考了ASUS論壇，https://www.asus.com/zentalk/tw/thread-164392-1-1.html，走到降版的步驟就出現錯誤訊息[INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE]&lt;br /&gt;
&lt;br /&gt;
終於翻到論壇的第十頁，貌似找到解答了，我把成功的command貼出：&lt;br /&gt;
&lt;br /&gt;
First，一定要先依照阿達的分享將手機與電腦連結。&lt;br /&gt;
Second，就照ASUS論壇把ADB搞定吧~&lt;br /&gt;
&lt;br /&gt;
【原手機步驟】&lt;br /&gt;
1. adb devices&lt;br /&gt;
--&amp;gt; 出現以連線的手機序號&lt;br /&gt;
&lt;br /&gt;
2. adb shell content query --uri content://settings/secure --where &quot;name=\&#39;android_id\&#39;&quot;&lt;br /&gt;
--&amp;gt;Row: 0 _id=25, name=android_id, value=xxxxxxxxxxxxxxxx(請好好保存android_id)&lt;br /&gt;
&lt;br /&gt;
3. adb shell pm uninstall -k jp.naver.line.android&lt;br /&gt;
--&amp;gt;Success&lt;br /&gt;
(移除原手機的line ?! 此時我的手機 ES應用分析器跑出來問要不要刪除line的相關檔案，別理他)&lt;br /&gt;
&lt;br /&gt;
4. adb push LINEold.apk /sdcard/&lt;br /&gt;
--&amp;gt; 複製舊版apk到手機&lt;br /&gt;
&lt;br /&gt;
5. adb shell pm install /sdcard/LINEold.apk&lt;br /&gt;
--&amp;gt;Success (Line降版，裝好後不要開)&lt;br /&gt;
&lt;br /&gt;
6. adb backup -apk jp.naver.line.android&lt;br /&gt;
--&amp;gt;Now unlock your device and confirm the backup operation.&lt;br /&gt;
(手機畫面點&quot;備份我的資料&quot;，等一下直接檢查電腦檔案夾的backup.ab檔案大小，1K就是失敗了，至少要來個10MB)&lt;br /&gt;
&lt;br /&gt;
【新手機步驟(先移除任何版本LINE)】&lt;br /&gt;
1. adb install LINEold.apk&lt;br /&gt;
2. adb shell settings put secure android_id xxxxxxxxxxxxxxxx(第2步驟取的android_id共16碼)&lt;br /&gt;
3. adb restore backup.ab&lt;br /&gt;
(手機畫面點&quot;還原我的資料&quot;)&lt;br /&gt;
&lt;br /&gt;
馬上開新手機的Line絕對是不work的，此時不用擔心，到Play Store更新Line版本。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/8393243614471131563/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2017/03/line-backup-line-root-v711.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8393243614471131563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8393243614471131563'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2017/03/line-backup-line-root-v711.html' title='[Line Backup] Line 對話紀錄免Root無痛轉移 v7.1.1'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-5020991416879048149</id><published>2011-08-24T22:29:00.000+08:00</published><updated>2011-08-24T22:34:09.319+08:00</updated><title type='text'>[ASP.NET] Import Excel with linqtoexcel</title><content type='html'>&lt;a href=&quot;http://wupinny.blogspot.com/2011/07/aspnet-export-excel-with-npoi-and.html&quot;&gt;上篇文章&lt;/a&gt;比較了以NPOI and EPPlus匯出Excel的效能，接著就是要介紹Import Excel了，雖然NPOI也可以Import Excel2003/2007，但我認識了&lt;a href=&quot;http://code.google.com/p/linqtoexcel/&quot;&gt;linqtoexcel&lt;/a&gt;後，就毅然決然的選用LinqToExcel為我的Import利器了。&lt;br /&gt;
LinqToExcel為32位元的dll，所以如果在64位元遇到complier的問題時，請參閱轉載自網路的&lt;a href=&quot;http://cloudolphinstudy.blogspot.com/2011/02/could-not-load-file-or-assembly.html&quot;&gt;排除方法&lt;/a&gt;。 還有&lt;a href=&quot;http://code.google.com/p/linqtoexcel/wiki/UsingLinqToExcel&quot;&gt;注意事項&lt;/a&gt;，轉載自官網：  &lt;br /&gt;
&lt;blockquote&gt;
&lt;b&gt;Target x86 Platform&lt;/b&gt; Linq to Excel requires any projects referencing it to be built against the x86 platform target. See &lt;a href=&quot;http://blog.yodersolutions.com/2008/11/microsoftjetoledb-and-x64-machines/&quot;&gt;this link&lt;/a&gt; for detailed information on setting the platform target to x86. Note this only applies to compiling the project on x64 computers.   &lt;br /&gt;
&lt;b&gt;.Net 4&lt;/b&gt; When using Linq to Excel in a .Net 4 app, make sure to change the target framework from the default client profile to the full .Net 4 framework. (Properties -&amp;gt; Application -&amp;gt; Target framework) The client profile cannot compile .Net 3.5 dlls. &lt;/blockquote&gt;
&lt;b&gt;檢而言之，只能跑在x64，跟.Net framework 3.5。&lt;/b&gt;   接著用官網的sample code介紹這好用的工具。  &lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;var excel = new ExcelQueryFactory(&quot;excelFileName&quot;);
var oldCompanies = from c in repo.Worksheet&lt;company&gt;(&quot;US Companies&quot;) //worksheet name = &#39;US Companies&#39;
                   where c.LaunchDate &amp;lt; new DateTime(1900, 0, 0)
                   select c;
&lt;/company&gt;&lt;/pre&gt;
首先讀取名字為&quot;US Companies&quot;的工作表，如果無法確定上傳的檔案的名稱，最好傳入index即可。&lt;br /&gt;
 接著&lt;span class=&quot;pun&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Company&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;/span&gt;則是有一個名叫Company的Class與Excel 的欄位都一模一樣， 這樣檔案就會乖乖的資料吃到Company的集合物件， 並可以用linq的手法去做資料篩選，一整個就是美妙。&lt;br /&gt;
&lt;br /&gt;
  不過如果Excel欄位與Class無法設定成一樣的，那還是有法可解： &lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;var excel = new ExcelQueryFactory(&quot;excelFileName&quot;);
excel.AddMapping&lt;company&gt;(x =&amp;gt; x.State, &quot;Providence&quot;); //maps the &quot;State&quot; property to the &quot;Providence&quot; column

var indianaCompanies = from c in excel.Worksheet&lt;company&gt;()
                       where c.State == &quot;IN&quot; &amp;amp;&amp;amp; c.Employees &amp;gt; 500
                       select c;
&lt;/company&gt;&lt;/company&gt;&lt;/pre&gt;
使用AddMapping去指定欄位間的關係，Excel欄位 &quot;Providence&quot;去指定對應到Company的State的欄位。</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/5020991416879048149/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2011/08/aspnet-import-excel-with-linqtoexcel.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/5020991416879048149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/5020991416879048149'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2011/08/aspnet-import-excel-with-linqtoexcel.html' title='[ASP.NET] Import Excel with linqtoexcel'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-1170874324490174550</id><published>2011-07-26T08:20:00.004+08:00</published><updated>2011-07-26T08:24:25.780+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>[ASP.NET] Export Excel with NPOI and EPPlus</title><content type='html'>&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;NPOI：&lt;/b&gt;使用於(Excel2003及之前的版本)，可寫出Excel2003(xls)，可讀Excel2003 (xls)/ Excel2007(xlsx)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
官網:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://npoi.codeplex.com/&quot;&gt;http://npoi.codeplex.com/&lt;/a&gt; (~1.2.3)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://code.google.com/p/npoi/&quot;&gt;http://code.google.com/p/npoi/&lt;/a&gt; (1.2.4)&lt;/li&gt;
&lt;/ul&gt;
System Requirement:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;VS2005 or VS2008 with .NET 2.0 Runtime (SP1)&lt;/li&gt;
&lt;li&gt;vs2003 with .NET 1.1&lt;/li&gt;
&lt;li&gt;medium trust environment in ASP.NET&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;EPPlus：&lt;/b&gt;EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
官網：&lt;a href=&quot;http://epplus.codeplex.com/&quot;&gt;http://epplus.codeplex.com/&lt;/a&gt;&lt;br /&gt;
System Requirements:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;.Net Framwork 3.5 or higher&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;&lt;/ul&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;NPOI vs. EPPlus：比較匯出大量資料的時間&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;NPOI： &lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;private void ExportNPOI()
{
    logger.Info(&quot;begin npoi&quot;);

    HSSFWorkbook workbook = new HSSFWorkbook();
    MemoryStream ms = new MemoryStream();
    HSSFSheet sheet = workbook.CreateSheet();

    for (int i = 0; i &amp;lt; 65535; i++)
    {
        HSSFRow row = sheet.CreateRow(i);
        row.CreateCell(0).SetCellValue(&quot;npoiformats&quot;);
    }

    workbook.Write(ms);

    logger.Info(&quot;end npoi&quot;);

    Response.ContentType = &quot;application/download&quot;;
    Response.AddHeader(&quot;Content-Disposition&quot;, &quot;attachment; filename=file.xls&quot;);
    Response.Clear();
    Response.BinaryWrite(ms.GetBuffer());

    ms.Close();
    ms.Dispose();
}
&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;EPPlus： &lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;private void ExportEPPlus()
{
    logger.Info(&quot;begin epplus&quot;);
    
    ExcelPackage pck = new ExcelPackage();
    var ws = pck.Workbook.Worksheets.Add(&quot;Sample2&quot;);

    for (int i = 1; i &amp;lt; 65999; i++)
    {
        ws.Cells[i, 1].Value = &quot;openxmlformats&quot;;	//Set the value of cell A1 to 1
        ws.Cells[i, 2].Value = &quot;openxmlformats&quot;;
        ws.Cells[i, 3].Value = &quot;openxmlformats&quot;;
        ws.Cells[i, 4].Value = &quot;openxmlformats&quot;;
        ws.Cells[i, 5].Value = &quot;openxmlformats&quot;;
    }

    logger.Info(&quot;end epplus&quot;);

    Response.Clear();
    Response.AddHeader(&quot;content-disposition&quot;, &quot;attachment; filename=file.xlsx&quot;);
    Response.ContentType = &quot;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&quot;;
    Response.BinaryWrite(pck.GetAsByteArray());
    Response.End();            
}
&lt;/pre&gt;
Excel2007可會出超過65535筆資料。&lt;br /&gt;
使用NPOI產出65535筆資料花費41 sec，我測試的最佳紀錄為25秒。&lt;br /&gt;
使用EPPlus產出65999筆花費2 sec。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Log File： &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:text&quot;&gt;2011-07-21 15:09:18.8851|INFO|ExcelCompare._Default|begin npoi
2011-07-21 15:09:59.2133|INFO|ExcelCompare._Default|end npoi

2011-07-21 15:10:02.4633|INFO|ExcelCompare._Default|begin epplus
2011-07-21 15:10:04.7758|INFO|ExcelCompare._Default|end epplus
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/1170874324490174550/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-export-excel-with-npoi-and.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/1170874324490174550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/1170874324490174550'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-export-excel-with-npoi-and.html' title='[ASP.NET] Export Excel with NPOI and EPPlus'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-172684457663566781</id><published>2011-07-19T23:16:00.001+08:00</published><updated>2011-07-26T08:24:09.182+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><title type='text'>[ASP.NET] 解決Oracle IN clause 超過1000個參數</title><content type='html'>不管在SQL Plus或其他Tool，甚至ASP.NET中，只要出現以下錯誤訊息：&lt;br /&gt;
&lt;span id=&quot;_ctl5_ctlTopic&quot;&gt;&lt;span id=&quot;_ctl5_ctlTopic_ctlPanelBar&quot;&gt;&lt;span id=&quot;_ctl5_ctlTopic_ctlPanelBar_ctlTopicsRepeater__ctl4_lblFullMessage&quot;&gt;&lt;b&gt;ORA-01795 maximum number of expressions in a list is 1000&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span id=&quot;_ctl5_ctlTopic&quot;&gt;&lt;span id=&quot;_ctl5_ctlTopic_ctlPanelBar&quot;&gt;&lt;span id=&quot;_ctl5_ctlTopic_ctlPanelBar_ctlTopicsRepeater__ctl4_lblFullMessage&quot;&gt;不用懷疑&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;，就是你的SQL中，IN的參數超過1000個了。&lt;br /&gt;
&lt;br /&gt;
最快的解決方法有兩種：&lt;br /&gt;
1. OR&lt;br /&gt;
2. Union&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OR &lt;/b&gt;Sample如下：&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;select * from TestTable where ID in (1,2,3,4,...,1000)
union all
select * from TestTable where ID in (1001,1002,...)
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Union &lt;/b&gt;Sample如下：&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;select * from TestTable where ID in (1,2,3,4,...,1000) or ID in (1001,1002,...,2000)
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
在ASP.NET中，Sample如下(使用OR)：&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;strSQL = &quot;select * from TestTable where {0} &quot;;
int limitCount = 900;
                double dLoopCycle = (IDs.Count / limitCount);
                int loopCycle = Convert.ToInt32(Math.Ceiling(dLoopCycle));
                loopCycle = loopCycle == 0 ? 1 : loopCycle;

                string strIDs = string.Empty;
                string strTempSQL = string.Empty;
                //more than 1000 parameter would raise error
                for (int i = 0; i &amp;lt; loopCycle; i++)
                {
                    int rangeIndex = (i * limitCount);
                    List&lt;string&gt; tempList = IDs.GetRange(rangeIndex, Math.Min(limitCount, IDs.Count - rangeIndex));

                    strIDs = string.Join(&quot;,&quot;, tempList.ToArray());
                    if (i == 0)
                        strTempSQL = string.Format(&quot;ID in ({0})&quot;, strIDs);
                    else
                        strTempSQL += string.Format(&quot;or ID in ({0}) &quot;, strIDs);
                }

strSQL = string.Format(strSQL, strTempSQL);
&lt;/string&gt;&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/172684457663566781/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-oracle-in-clause-1000.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/172684457663566781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/172684457663566781'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-oracle-in-clause-1000.html' title='[ASP.NET] 解決Oracle IN clause 超過1000個參數'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-4100306674992731323</id><published>2011-07-19T22:48:00.001+08:00</published><updated>2011-07-26T08:23:03.927+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="LINQ"/><title type='text'>[ASP.NET] 解決Linq Contain 參數超過2100的錯誤</title><content type='html'>在Linq使用Contain時，必須注意參數的個數，限制為2100為上限，錯誤訊息如下：&lt;br /&gt;
&lt;b&gt;The incoming tabular data stream (TDS) remote procedure call (RPC)  protocol stream is incorrect. Too many parameters were provided in this  RPC request. The maximum is 2100.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
表示你踩到IN Parameter最多2100個的限制。&lt;br /&gt;
&lt;br /&gt;
以下為我的解決之道：&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;double dLoopCycle = (containList.Count / 2000);
int loopCycle = Convert.ToInt32(Math.Ceiling(dLoopCycle));
loopCycle = loopCycle == 0 ? 1 : loopCycle;

List&lt;test&gt; result = new List&lt;test&gt;();
List&lt;test&gt; tempResult = new List&lt;test&gt;();
 //more than 2100 parameter would raise error
 for (int i = 0; i &amp;lt; loopCycle; i++)
 {
     int rangeIndex = (i * 2000);
     var tempList = containList.GetRange(rangeIndex, Math.Min(2000, containList.Count - rangeIndex));

     tempResult = (from r in DataContext.Test where tempList.Contain(r.ID) select r).ToList();
     result = result.Union(tempResult );
}

&lt;/test&gt;&lt;/test&gt;&lt;/test&gt;&lt;/test&gt;&lt;/pre&gt;
&lt;br /&gt;
另外oracle的SQL也有IN Parameter不得超過1000個的限制，這個就會在後續的文章分享我的解決方式囉~~&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://wupinny.blogspot.com/2011/07/aspnet-oracle-in-clause-1000.html&quot;&gt;[ASP.NET] 解決Oracle IN clause 超過1000個參數&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/4100306674992731323/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-linq-contain-2100.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/4100306674992731323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/4100306674992731323'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-linq-contain-2100.html' title='[ASP.NET] 解決Linq Contain 參數超過2100的錯誤'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-5860256156051728493</id><published>2011-07-13T22:24:00.006+08:00</published><updated>2011-07-19T22:52:25.117+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>[ASP.NET] Nlog：記Log必備的好東西</title><content type='html'>要瞭解Nlog初步認識一定必須先拜讀保哥的的大作，&lt;span style=&quot;font-size: small;&quot;&gt;&lt;a class=&quot;taggedlink&quot; href=&quot;http://blog.miniasp.com/post/2010/07/18/Useful-Library-NLog-Advanced-NET-Logging.aspx&quot;&gt;介紹好用函式庫：NLog - Advanced .NET Logging&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;當然師傅引進門，詳細的設定就是要靠自己啦...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;就如保哥所說的，install之後就有完整的API文件跟範例，&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;其實不外乎只要把 Nlog.config 設定好，就完成大半的工作了!!!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;我的設定主要：&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;1.存成File的部分，七天回滾一次，自動刪除過期的Log，讓Disk不會被擠爆。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;2.寄出Mail的部分，集滿五個拉環才寄出，不會一個Message寄發信，讓我的信箱不被塞爆。&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;首先附上我的Nlog.config&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&lt;nlog autoreload=&quot;true&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://www.nlog-project.org/schemas/NLog.xsd&quot;&gt;

    &lt;targets&gt;
        
        &lt;target archiveevery=&quot;Day&quot; archivefilename=&quot;${basedir}/archives/log.{#}.txt&quot; archivenumbering=&quot;Rolling&quot; concurrentwrites=&quot;true&quot; encoding=&quot;iso-8859-2&quot; filename=&quot;${basedir}/logs/logfile.txt&quot; keepfileopen=&quot;false&quot; layout=&quot;${longdate} ${logger} ${message}&quot; maxarchivefiles=&quot;7&quot; name=&quot;file&quot; xsi:type=&quot;File&quot;&gt;
        &lt;target buffersize=&quot;5&quot; name=&quot;mail&quot; xsi:type=&quot;BufferingWrapper&quot;&gt;
            &lt;target from=&quot;email@xxx.com&quot; layout=&quot;${longdate}|${level:uppercase=true}|${logger}|${message}${newline}&quot; smtpserver=&quot;smtpserver&quot; subject=&quot;[Alert]subject&quot; to=&quot;pinny@xxx.com.tw&quot; xsi:type=&quot;Mail&quot;&gt;
        &lt;/target&gt;
    &lt;/target&gt;&lt;/target&gt;&lt;/targets&gt;

    &lt;rules&gt;
        &lt;logger minlevel=&quot;Debug&quot; name=&quot;*&quot; writeto=&quot;file&quot;&gt;
        &lt;logger minlevel=&quot;Warn&quot; name=&quot;*&quot; writeto=&quot;mail&quot;&gt;
    &lt;/logger&gt;&lt;/logger&gt;&lt;/rules&gt;
&lt;/nlog&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Config檔案分成兩大塊，targets 與rules&lt;/span&gt;&lt;br /&gt;
targets主要是設定Log要紀錄的方式&lt;br /&gt;
rules主要則是決定紀錄Log的level與輸出的方式&lt;br /&gt;
&lt;br /&gt;
我的targets的設定針對兩個紀錄方式：File / Mail&lt;br /&gt;
針對File的部分，奧妙的地方：&lt;br /&gt;
1. layout =&amp;gt; 寫入Log的內容 (時間+程式名稱+Message)&lt;br /&gt;
2. archive相關 =&amp;gt; 以Day切Log檔，最多存7個檔案，超過一週就會被覆蓋&lt;br /&gt;
詳細可看&lt;a href=&quot;http://nlog-project.org/wiki/File_target#Time-based_file_archival&quot;&gt;官網範例&lt;/a&gt;&lt;br /&gt;
針對Mail的部分，奧妙的地方：&lt;br /&gt;
1.設定SMTP等mail setting是一定要的&lt;br /&gt;
2.其中bufferSize則是集滿拉環才寄出，不然將會一個log message就丟出一封信來，當然如果只有兩則message在程式結束後也會mail出來&lt;br /&gt;
&lt;br /&gt;
針對rules就相對簡單易懂了，minlevel就是比你設定的level嚴重的才記log&lt;br /&gt;
log level依序越來越嚴重：&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt; Trace.log
&lt;/li&gt;
&lt;li&gt; Debug.log
&lt;/li&gt;
&lt;li&gt; Info.log
&lt;/li&gt;
&lt;li&gt; Warn.log
&lt;/li&gt;
&lt;li&gt; Error.log
&lt;/li&gt;
&lt;li&gt; Fatal.log
&lt;/li&gt;
&lt;/ul&gt;
我的設定就是Debug嚴重度以上的都要紀錄在File中&lt;br /&gt;
Warm嚴重度以上的才寄信通知我!!!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/5860256156051728493/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-nloglog.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/5860256156051728493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/5860256156051728493'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2011/07/aspnet-nloglog.html' title='[ASP.NET] Nlog：記Log必備的好東西'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-3761737559163295953</id><published>2010-12-20T21:35:00.001+08:00</published><updated>2010-12-20T21:39:22.400+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="Update"/><title type='text'>[Oracle]Update data from another Table</title><content type='html'>Web系統不免會有由Excel Upload的資料去更新資料表的需求，當然如果Excel資料一筆一筆的對Table做更新是不符合效益，這將造成對database的transaction過多，而且因為目前需Update的資料表資料量相當大，所以採用的方法如下：&lt;br /&gt;
1.Insert data in db temp table from excel data&lt;br /&gt;
2.update data from temp table&lt;br /&gt;
&lt;br /&gt;
上述的從Temp table取用資料Update資料表，就切入本篇的主題，可用的方法有三：&lt;br /&gt;
1.Update by sub-query&lt;br /&gt;
2.Update table view&lt;br /&gt;
3.Merge&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;方法一：&lt;/b&gt;&lt;/div&gt;&lt;pre class=&quot;brush:sql&quot;&gt;UPDATE bigTable b
   SET (col1,col2,col3) = (
       SELECT t.col1,t.col2,t.col3
         FROM tempTable t
        WHERE b.col = t.col)
where exists(
       SELECT t.col1,t.col2,t.col3
         FROM tempTable t
        WHERE b.col = t.col);
&lt;/pre&gt;&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;方法二：&lt;/b&gt;&lt;/div&gt;&lt;pre class=&quot;brush:sql&quot;&gt;UPDATE (
SELECT b.col1 as old_col1,
       b.col2 as old_col2,
       b.col3 as old_col3,
       t.col1 as new_col1,
       t.col2 as new_col2,
       t.col3 as new_col3 
  FROM bigTable b, tempTable t
 WHERE b.col = t.col)
   SET old_col1 = new_col1,
       old_col2 = new_col2,
       old_col3 = new_col3;
&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;方法三：&lt;/b&gt;&lt;/div&gt;&lt;pre class=&quot;brush:sql&quot;&gt;MERGE INTO bigTable b
 USING (SELECT col1 , col2 , col3 , col
          tempTable t ) t
    ON ( b.col = t.col)
WHEN matched THEN
UPDATE
   SET old_col1 = new_col1,
       old_col2 = new_col2,
       old_col3 = new_col3;
&lt;/pre&gt;&lt;br /&gt;
測試結果：&lt;br /&gt;
方法一：140 sec&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;方法二：1 sec&lt;/b&gt;&lt;/div&gt;方法三：未測&lt;br /&gt;
&lt;br /&gt;
透過方法二 明顯是效能最佳的解法，但若會被update的bigTable並非符合UK或PK的條件，將會產生&lt;b&gt;&quot;ORA-01779: cannot modify a column which maps to a non-key-preserved table&quot;&lt;/b&gt;的錯誤，若你的table不適合建立UK或PK時，可透過hint的方式&lt;b style=&quot;color: red;&quot;&gt;/*+ BYPASS_UJVC */&lt;/b&gt;來忽略UK的檢查。&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;UPDATE (
SELECT /*+ BYPASS_UJVC */ b.col1 as old_col1,
       b.col2 as old_col2,
       b.col3 as old_col3,
       t.col1 as new_col1,
       t.col2 as new_col2,
       t.col3 as new_col3 
  FROM bigTable b, tempTable t
 WHERE b.col = t.col)
   SET old_col1 = new_col1,
       old_col2 = new_col2,
       old_col3 = new_col3;
&lt;/pre&gt;&lt;br /&gt;
參考網址：&lt;a href=&quot;http://blog.csdn.net/yuhua3272004/archive/2008/08/06/2776121.aspx&quot;&gt;http://blog.csdn.net/yuhua3272004/archive/2008/08/06/2776121.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/3761737559163295953/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/12/oracleupdate-data-from-another-table.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/3761737559163295953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/3761737559163295953'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/12/oracleupdate-data-from-another-table.html' title='[Oracle]Update data from another Table'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-509199407843899661</id><published>2010-11-17T23:28:00.000+08:00</published><updated>2010-11-17T23:28:12.013+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><title type='text'>[Oracle]處理中文亂碼 -- NLS_LANG設定</title><content type='html'>開發連結oracle資料庫不可不注意中文的處理問題&lt;br /&gt;
&lt;br /&gt;
首先必須確認DB Server的編碼設定&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;select userenv(&#39;language&#39;) from dual;
&lt;/pre&gt;取得結果為TRADITIONAL_CHINESE.TAIWAN.ZHT16BIG5&lt;br /&gt;
&lt;br /&gt;
接下來就是設定client端的NLS_LANG，只要與DB Server相同，中文顯示就會正確了&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. 開始 -&amp;gt; 執行 -&amp;gt; regedit&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;2. 找出 HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;3. NLS_LANG改為TRADITIONAL_CHINESE.TAIWAN.ZHT16BIG5&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
這樣由這台client連到TRADITIONAL_CHINESE.TAIWAN.ZHT16BIG5 的DB Server中文顯示就會是正確的。&lt;br /&gt;
&lt;br /&gt;
另一個議題，單一client要連結的DB Server有多種NLS_LANG，擔任Web Server的client常有這種狀況!!!&lt;br /&gt;
&lt;br /&gt;
以ASP.NET為例：&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp&quot;&gt;public void ReadMyData(string connectionString)
{
    //設定Oracle NLS_LANG,在connect db前設定環境變數
    System.Environment.SetEnvironmentVariable(&quot;NLS_LANG&quot;, &quot;AMERICAN_AMERICA.ZHT32EUC&quot;);
    string queryString = &quot;SELECT OrderID, CustomerID FROM Orders&quot;;
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        OleDbCommand command = new OleDbCommand(queryString, connection);
        connection.Open();
        OleDbDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            Console.WriteLine(reader.GetInt32(0) + &quot;, &quot; + reader.GetString(1));
        }
        // always call Close when done reading.
        reader.Close();
    }
}

&lt;/pre&gt;&lt;br /&gt;
其關鍵就是&lt;br /&gt;
&lt;pre style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;System.Environment.&lt;wbr&gt;&lt;/wbr&gt;SetEnvironmentVariable(&quot;NLS_&lt;wbr&gt;&lt;/wbr&gt;LANG&quot;,&quot;AMERICAN_AMERICA.ZHT32EUC&quot;);&lt;/span&gt;&lt;/b&gt;&lt;/pre&gt;&lt;pre style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/pre&gt;&lt;pre style=&quot;color: black;&quot;&gt;針對&lt;span lang=&quot;EN-US&quot;&gt;單一Web Site設定連線到DB NLS_LANG，&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;就可以一勞永逸的解決中文問題，不管程式被Deploy到哪裡，
都不受那台Web Server的NLS_Lang影響。&lt;/span&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/509199407843899661/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/11/oracle-nlslang.html#comment-form' title='4 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/509199407843899661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/509199407843899661'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/11/oracle-nlslang.html' title='[Oracle]處理中文亂碼 -- NLS_LANG設定'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-9199896913113853767</id><published>2010-10-11T21:15:00.004+08:00</published><updated>2010-10-11T21:19:49.825+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>[ASP.NET]Visual Studio建立N-Tier的Solution</title><content type='html'>於Visual Studio實現N-Tier，目前將程式分為三層:&lt;br /&gt;
1.UI (Web Form)&lt;br /&gt;
2.BLL (Bussiness Logic Layer)&lt;br /&gt;
3.DAL (Data Access Layer)&lt;br /&gt;
&lt;br /&gt;
要建立起這樣的架構，首先必須建立一個空白專案，我們可用此專案開啟我們的N-Tier全部檔案來檢視。&lt;br /&gt;
&lt;b&gt;1.建立空白專案 &lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzWu6rcACQvkkrFlpbfz8h00jU-kqluChL4-aEs4hY_3pKWt6vMjgFk8vv4pdb2G0H09HO_7ZyzaKvkS3aE2VsJaOrNIPZL2yKUXgz6uULb8qnBJoxvSMALrVbW2Wq7y0VMbAtjHNkC1iw/s1600/2010-10-11_135649.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzWu6rcACQvkkrFlpbfz8h00jU-kqluChL4-aEs4hY_3pKWt6vMjgFk8vv4pdb2G0H09HO_7ZyzaKvkS3aE2VsJaOrNIPZL2yKUXgz6uULb8qnBJoxvSMALrVbW2Wq7y0VMbAtjHNkC1iw/s1600/2010-10-11_135649.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;2.建立Client檔案夾，加入Web Application 的Project&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq_-sN99xQbonOq5CaXxwxC3gRnDsvYz3v4s0EyYoEGPZFjqLaH3-u_zPeHhloxmE0AG3xLufWK4LAe7lum1qj2GzC7GkjPTHc1jSpglfO4xmmqaqKrpMNftty2jpBQrfq28OCH_2ohUMB/s1600/2010-10-11_140415.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq_-sN99xQbonOq5CaXxwxC3gRnDsvYz3v4s0EyYoEGPZFjqLaH3-u_zPeHhloxmE0AG3xLufWK4LAe7lum1qj2GzC7GkjPTHc1jSpglfO4xmmqaqKrpMNftty2jpBQrfq28OCH_2ohUMB/s320/2010-10-11_140415.png&quot; width=&quot;280&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYT6b6IYE2DG97WRkzQLdByWYUqfYWM6X_Ob5vHaum6vWt3VjM_YcJZq2IKQuW2RbzrBUqI4Vnbb8Is2WBuXs_O3koTjHD-BgASd5VxB1vAL_mb7dqEjErVtyb_g6lKmDQkN-tXCMQbJmA/s1600/2010-10-11_140509.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;189&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYT6b6IYE2DG97WRkzQLdByWYUqfYWM6X_Ob5vHaum6vWt3VjM_YcJZq2IKQuW2RbzrBUqI4Vnbb8Is2WBuXs_O3koTjHD-BgASd5VxB1vAL_mb7dqEjErVtyb_g6lKmDQkN-tXCMQbJmA/s320/2010-10-11_140509.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;3.建立General檔案夾，建立BLL與DAL的Project&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6fuHdGKLGkKXcE4WL6bX546ff0SW7EtGHSLQ4lrerDHqMw38YeyCVRYWnltdaqCkA66eIEulLAZVTiMyMx42psxuuLPCb_VWIw_2sGf2fOuao_-AX6msr2-F1DsuPtl88UGb4hURFNtxk/s1600/2010-10-11_140550.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6fuHdGKLGkKXcE4WL6bX546ff0SW7EtGHSLQ4lrerDHqMw38YeyCVRYWnltdaqCkA66eIEulLAZVTiMyMx42psxuuLPCb_VWIw_2sGf2fOuao_-AX6msr2-F1DsuPtl88UGb4hURFNtxk/s320/2010-10-11_140550.png&quot; width=&quot;222&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUn4EVGZG38CuPSrmxv5aG1eah3EGZuaLl_puaWIWHHptF9Vx2QuAIfHkJttp2nzD6l06-p_vfEghb0ko10-c7Ja8riaaMcZb_c-4gpAQ8wvQIAeWjBk1VFpovrQyM0-lkyATa5xJ7aAqT/s1600/2010-10-11_140618.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUn4EVGZG38CuPSrmxv5aG1eah3EGZuaLl_puaWIWHHptF9Vx2QuAIfHkJttp2nzD6l06-p_vfEghb0ko10-c7Ja8riaaMcZb_c-4gpAQ8wvQIAeWjBk1VFpovrQyM0-lkyATa5xJ7aAqT/s400/2010-10-11_140618.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4.檢視建立完畢的Solution&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ws85FHOsfTB-oc1drMopqtWoueGDZR_P6wv5CnwtY7sKqRbX6CJrVTbQM-TTAztSZeDJNYQoXOwGpULBRDsP93GdW980U3dBFBJHtMlnJYpxAFepj_PGWt6_ogSoPMbYvBZz77KTu0Qy/s1600/2010-10-11_140725.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ws85FHOsfTB-oc1drMopqtWoueGDZR_P6wv5CnwtY7sKqRbX6CJrVTbQM-TTAztSZeDJNYQoXOwGpULBRDsP93GdW980U3dBFBJHtMlnJYpxAFepj_PGWt6_ogSoPMbYvBZz77KTu0Qy/s1600/2010-10-11_140725.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5.各Layer間要加入Reference，這樣就可以把整個Solution關係都拉起來了~&lt;/b&gt;&lt;br /&gt;
首先，BLL將DAL加入Reference，&lt;br /&gt;
接著就是在Web Application加入BLL與DAL。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-WYYvvhgqJLn1phyF0yGzx7ToMJmatJ49R5XqSTj8nydfJ3tXz5AfPbR3OQcQh9fJ2AiQ91mGuXDpHFRlLtloARSSKQd0mKqJ58YUSrxt9GEkC_3Uvc7402Kz4wC6HSyELqkVwOsPgAWH/s1600/2010-10-11_140824.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-WYYvvhgqJLn1phyF0yGzx7ToMJmatJ49R5XqSTj8nydfJ3tXz5AfPbR3OQcQh9fJ2AiQ91mGuXDpHFRlLtloARSSKQd0mKqJ58YUSrxt9GEkC_3Uvc7402Kz4wC6HSyELqkVwOsPgAWH/s400/2010-10-11_140824.png&quot; width=&quot;224&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2lGSoowjN37YW3auTK6xiN_vr3vLVsu-TnMYBIeKukZ-bbh80vhX3K1gVn5GmtQeis8jktFc5bBbUnywpREaJDzp1UIX8HSePG39DoxxEWXOSg3h9H3p0N7Q-Ui-xafGxJzn0J4iQxOeh/s1600/2010-10-11_140910.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;284&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2lGSoowjN37YW3auTK6xiN_vr3vLVsu-TnMYBIeKukZ-bbh80vhX3K1gVn5GmtQeis8jktFc5bBbUnywpREaJDzp1UIX8HSePG39DoxxEWXOSg3h9H3p0N7Q-Ui-xafGxJzn0J4iQxOeh/s400/2010-10-11_140910.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;6.檢視整個Solution加入Reference後的結果&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYpo9nH2wm0I8d4HHWZSQ1igZzh2Fb4qGa8033q8KaNdIuJ9QBm-GAEOUDQg7vdpb2JCO5nYKYsGj0smd1Y6QBAZbGKJwvjaldBVRIBkqQVDBYc2Z_RhCI9BMYELpWrXlecPMcXx6w64zA/s1600/2010-10-11_140957.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYpo9nH2wm0I8d4HHWZSQ1igZzh2Fb4qGa8033q8KaNdIuJ9QBm-GAEOUDQg7vdpb2JCO5nYKYsGj0smd1Y6QBAZbGKJwvjaldBVRIBkqQVDBYc2Z_RhCI9BMYELpWrXlecPMcXx6w64zA/s1600/2010-10-11_140957.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
這樣就大致的把3-Tier切出來了，&lt;br /&gt;
透過如此的切法，&lt;br /&gt;
DAL主要只負責用來連結資料庫，對資料庫做資料處理。&lt;br /&gt;
BLL則是扮演DAL與UI之前的橋樑，對於取出資料庫取出的資料作邏輯處理，回覆資料給UI。&lt;br /&gt;
UI則是單純的扮演呼叫BLL與呈現資料，不做邏輯處理與判斷。</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/9199896913113853767/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/10/aspnetvisual-studion-tiersolution.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/9199896913113853767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/9199896913113853767'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/10/aspnetvisual-studion-tiersolution.html' title='[ASP.NET]Visual Studio建立N-Tier的Solution'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzWu6rcACQvkkrFlpbfz8h00jU-kqluChL4-aEs4hY_3pKWt6vMjgFk8vv4pdb2G0H09HO_7ZyzaKvkS3aE2VsJaOrNIPZL2yKUXgz6uULb8qnBJoxvSMALrVbW2Wq7y0VMbAtjHNkC1iw/s72-c/2010-10-11_135649.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-8788559982022604096</id><published>2010-06-07T21:45:00.004+08:00</published><updated>2010-06-07T21:48:09.243+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Analytic Functions"/><category scheme="http://www.blogger.com/atom/ns#" term="Group By"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><title type='text'>[Oracle]箱型圖(BoxPlot)統計值運算</title><content type='html'>繪製&lt;a href=&quot;http://zh.wikipedia.org/zh-tw/%E7%AE%B1%E5%BD%A2%E5%9C%96&quot;&gt;箱型圖&lt;/a&gt;顯示一組數據的分散情況，而若從資料庫中的Raw Data，來繪製箱型圖，則需結算出六個必要數值：最大值、最小值、中位數、平均值、Q1下&lt;a href=&quot;http://zh.wikipedia.org/zh-hant/%E5%9B%9B%E5%88%86%E4%BD%8D%E6%95%B0&quot;&gt;四分位數&lt;/a&gt;、Q3下&lt;a href=&quot;http://zh.wikipedia.org/zh-hant/%E5%9B%9B%E5%88%86%E4%BD%8D%E6%95%B0&quot;&gt;四分位數&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
以Oracle範例資料庫中的employees資料表為例，計算每個部門的箱型圖數值：&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCWy8xihQ6_OPujiN7hpuvigqhmqiYxGSz62hV4a7I8P36uHtjrgASNx6JTyvpraeJP3phqIQsW5PNTzr-VsR_1HHt1skJ-hiKMbG8TYO-dwnjDCm9npuUCQE2vQBoNrDxriS3agkZ46e8/s1600/boxplot_data.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;211&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCWy8xihQ6_OPujiN7hpuvigqhmqiYxGSz62hV4a7I8P36uHtjrgASNx6JTyvpraeJP3phqIQsW5PNTzr-VsR_1HHt1skJ-hiKMbG8TYO-dwnjDCm9npuUCQE2vQBoNrDxriS3agkZ46e8/s640/boxplot_data.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:sql&quot;&gt;select department_id,
       max(salary) Upper_whisker,
       min(salary) Lower_whisker,
       round(avg(salary),3) Average,
       PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY salary ASC) Q1,
       PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY salary ASC) Median,
       PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY salary ASC) Q3
  from employees t
 group by department_id&lt;/pre&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;PERCENTILE_CONT為Oracle中的特殊Analytic Function，用於計算群組數值中分佈的百分比&lt;/b&gt;，&lt;br /&gt;
以中位數為例，為該群組數值中，從小到大排列的第50%的數字，&lt;br /&gt;
PERCENTILE_CONT(&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;0.5&lt;/span&gt;&lt;/b&gt;)的0.5則代表第50%，&lt;br /&gt;
WITHIN GROUP (&lt;b style=&quot;color: red;&quot;&gt;ORDER BY salary ASC&lt;/b&gt;)則代表以薪水salary做從小到大的排列。&lt;br /&gt;
&lt;br /&gt;
下圖將部門代號為100的數值以Excel驗算中位數、Q1、Q3的數值&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5zyPTrJhkGOWrHzJW-e-3pOgFzvL9YEl-Kf44191Gjl9_q3Zw1o4OGDgsg1JEKKK0IA-igbl1JT3ZCpqH3EH4PhLyxf0VETGWrO5nS55kt_N1fy_gJmv5kTPr9Jd5F5D3tjBPwVFgdNFc/s1600/boxplot_excel.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;203&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5zyPTrJhkGOWrHzJW-e-3pOgFzvL9YEl-Kf44191Gjl9_q3Zw1o4OGDgsg1JEKKK0IA-igbl1JT3ZCpqH3EH4PhLyxf0VETGWrO5nS55kt_N1fy_gJmv5kTPr9Jd5F5D3tjBPwVFgdNFc/s640/boxplot_excel.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;參考資源：&lt;br /&gt;
&lt;a href=&quot;http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions110.htm#SQLRF00687&quot;&gt;OracleR Database SQL Reference - PERCENTILE_CONT&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://psoug.org/reference/analytic_functions.html&quot;&gt;Oracle Analytic Functions&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/8788559982022604096/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/06/oracleboxplot.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8788559982022604096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8788559982022604096'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/06/oracleboxplot.html' title='[Oracle]箱型圖(BoxPlot)統計值運算'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCWy8xihQ6_OPujiN7hpuvigqhmqiYxGSz62hV4a7I8P36uHtjrgASNx6JTyvpraeJP3phqIQsW5PNTzr-VsR_1HHt1skJ-hiKMbG8TYO-dwnjDCm9npuUCQE2vQBoNrDxriS3agkZ46e8/s72-c/boxplot_data.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-4610542922907413729</id><published>2010-05-27T23:20:00.007+08:00</published><updated>2010-06-07T21:59:20.091+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>[ASP.NET]左右ListBox選單(3) -- 非同步PostBack Trigger</title><content type='html'>&amp;nbsp;承&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html&quot;&gt;[ASP.NET]  左右ListBox選單(1) -- 按鈕Trigger&lt;/a&gt; 與&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnet-listbox2-javascript-trigger.html&quot;&gt;[ASP.NET] 左右ListBox選單(2) -- Javascript Trigger&lt;/a&gt;的主題，有介紹以雙擊(double click)去觸發PostBack，然而以javascript送出則會有整頁往後送的效果，網頁會閃爍。&lt;br /&gt;
本文介紹將Control放入Update Panel來避免頁面閃爍的現象，另以非同步的javascript去做PostBack，同時可達到雙擊的效果與簡短了程式碼的撰寫。&lt;br /&gt;
&lt;br /&gt;
首先，承&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html&quot;&gt;上文&lt;/a&gt;的Code：&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Control放入UpdatePanel中&lt;/li&gt;
&lt;li&gt;ListBox的Control內加入Double Click事件的Function&lt;/li&gt;
&lt;li&gt;__doPostBack(&#39;ButtonRight&#39;,&#39;&#39;)&amp;nbsp; 為非同步送出觸發ButtonRight 的事件&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;&lt;pre ;=&quot;&quot; class=&quot;brush:xml&quot; collapse:=&quot;&quot; true;=&quot;&quot;&gt;&amp;lt;asp:UpdatePanel ID=&quot;UpdatePanel1&quot; runat=&quot;server&quot;&amp;gt;
    &amp;lt;ContentTemplate&amp;gt;
        &amp;lt;table align=&quot;center&quot; class=&quot;style1&quot; style=&quot;width: 400px&quot;&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td align=&quot;left&quot; style=&quot;font-weight: bold; font-size: 13px; font-family: Arial&quot; width=&quot;150px&quot;&amp;gt;
                    可選擇的ProductID &amp;lt;/td&amp;gt;
                &amp;lt;td&amp;gt;
                    &amp;amp;nbsp; &amp;lt;/td&amp;gt;
                &amp;lt;td align=&quot;left&quot; style=&quot;font-weight: bold; font-size: 13px; font-family: Arial&quot;&amp;gt;
                    已選擇的ProductID &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;
            &amp;lt;tr&amp;gt;
                &amp;lt;td align=&quot;left&quot;&amp;gt;
                    &amp;lt;asp:ListBox ID=&quot;ListBoxLeft&quot; ondblclick=&quot;__doPostBack(&#39;ButtonRight&#39;,&#39;&#39;)&quot; runat=&quot;server&quot;
                        Rows=&quot;5&quot; SelectionMode=&quot;Multiple&quot; Width=&quot;150px&quot;&amp;gt;&amp;lt;/asp:ListBox&amp;gt;                                                    
                &amp;lt;/td&amp;gt;
                &amp;lt;td align=&quot;center&quot;&amp;gt;
                    &amp;lt;asp:Button ID=&quot;ButtonRight&quot; runat=&quot;server&quot; OnClick=&quot;ButtonRight_Click&quot; Text=&quot; &amp;gt; &quot;
                        Width=&quot;40px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
                    &amp;lt;br /&amp;gt;
                    &amp;lt;asp:Button ID=&quot;ButtonRightAll&quot; runat=&quot;server&quot; OnClick=&quot;ButtonRightAll_Click&quot; Text=&quot;&amp;gt;&amp;gt;&quot;
                        Width=&quot;40px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
                    &amp;lt;br /&amp;gt;
                    &amp;lt;asp:Button ID=&quot;ButtonLeft&quot; runat=&quot;server&quot; OnClick=&quot;ButtonLeft_Click&quot; Text=&quot; &amp;lt; &quot;
                        Width=&quot;40px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
                    &amp;lt;br /&amp;gt;
                    &amp;lt;asp:Button ID=&quot;ButtonLeftAll&quot; runat=&quot;server&quot; OnClick=&quot;ButtonLeftAll_Click&quot; Text=&quot;&amp;lt;&amp;lt;&quot;
                        Width=&quot;40px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
                &amp;lt;/td&amp;gt;
                &amp;lt;td align=&quot;left&quot;&amp;gt;
                    &amp;lt;asp:ListBox ID=&quot;ListBoxRight&quot; ondblclick=&quot;__doPostBack(&#39;ButtonLeft&#39;,&#39;&#39;);&quot; runat=&quot;server&quot; Rows=&quot;5&quot; SelectionMode=&quot;Multiple&quot; Width=&quot;150px&quot;&amp;gt;
                    &amp;lt;/asp:ListBox&amp;gt;
                &amp;lt;/td&amp;gt;
            &amp;lt;/tr&amp;gt;            
        &amp;lt;/table&amp;gt;
    &amp;lt;/ContentTemplate&amp;gt;
&amp;lt;/asp:UpdatePanel&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html&quot;&gt;[ASP.NET] 左右ListBox選單(1) -- 按鈕Trigger&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnet-listbox2-javascript-trigger.html&quot;&gt;[ASP.NET] 左右ListBox選單(2) -- Javascript Trigger&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnetlistbox3-postback-trigger.html&quot;&gt;[ASP.NET]左右ListBox選單(3) -- 非同步PostBack Trigger &lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/4610542922907413729/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnetlistbox3-postback-trigger.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/4610542922907413729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/4610542922907413729'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnetlistbox3-postback-trigger.html' title='[ASP.NET]左右ListBox選單(3) -- 非同步PostBack Trigger'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-254862618206733560</id><published>2010-05-26T23:47:00.004+08:00</published><updated>2010-06-07T21:59:41.411+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>[ASP.NET]左右ListBox選單(2) -- Javascript Trigger</title><content type='html'>承&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html&quot;&gt;[ASP.NET] 左右ListBox選單(1) -- 按鈕Trigger&lt;/a&gt; 的主題，選取Value後按下中間的四個按鈕觸發PostBack，本文將雙擊(double click)的動作加入觸發PostBack的行列，讓選取的時候更加方便與直覺。&lt;br /&gt;
&lt;br /&gt;
首先，承上文的Code：&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;之間加入javascript，雙擊時將送出form&lt;/li&gt;
&lt;li&gt;ListBox的Control內加入Double Click事件的Function，並加入一個hidden欄位&lt;/li&gt;
&lt;li&gt;CS頁面內加入接收雙擊ListBox時操作&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;&lt;b style=&quot;color: red;&quot;&gt;加入Javascript&lt;/b&gt; &lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;script language=&quot;javascript&quot;&amp;gt;
     function ListBox1_DoubleClick() {
       /* we will change value of this hidden field so  that inpage load event we can identify event.
       */
        document.forms[0].ListBox1Hidden.value = &quot;doubleclicked&quot;;
        document.forms[0].submit();
     }
&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;ListBox加入事件並加hidden 欄位&lt;/b&gt;&lt;/div&gt;&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;asp:ListBox ID=&quot;ListBoxLeft&quot; ondblclick=&quot;ListBox1_DoubleClick()&quot; runat=&quot;server&quot;
Rows=&quot;5&quot; SelectionMode=&quot;Multiple&quot; Width=&quot;150px&quot;&amp;gt;&amp;lt;/asp:ListBox&amp;gt;       
&amp;lt;input type=&quot;hidden&quot; name=&quot;ListBox1Hidden&quot; /&amp;gt; 
&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;cs頁面加入ListBox Double Click Code&lt;/b&gt;&lt;/div&gt;&lt;pre class=&quot;brush:c-sharp&quot;&gt;protected void Page_Load(object sender, EventArgs e)
{
    if (Request.Params[&quot;ListBox1Hidden&quot;] != null &amp;amp;&amp;amp; (string)Request.Params[&quot;ListBox1Hidden&quot;] == &quot;doubleclicked&quot;)
    {
        ButtonRight_Click(null,null);
    }
}&lt;/pre&gt;雙擊左方的ListBox則當成第一個向右按鈕被觸發。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html&quot;&gt;[ASP.NET]左右ListBox選單(1) -- 按鈕Trigger&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnet-listbox2-javascript-trigger.html&quot;&gt;[ASP.NET]左右ListBox選單(2) -- Javascript Trigger&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http:///#&quot;&gt;[ASP.NET]左右ListBox選單(3) -- 非同步PostBack Trigger &lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/254862618206733560/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnet-listbox2-javascript-trigger.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/254862618206733560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/254862618206733560'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnet-listbox2-javascript-trigger.html' title='[ASP.NET]左右ListBox選單(2) -- Javascript Trigger'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-2276809950264324020</id><published>2010-05-25T21:29:00.010+08:00</published><updated>2010-05-26T23:49:30.968+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>[ASP.NET]左右ListBox選單(1) -- 按鈕Trigger</title><content type='html'>以ListBox實做左方ListBox為可選擇之項目，右方ListBox為已選擇之項目，中間放置四個按鈕，分別為向右鈕/全選向右鈕/向左鈕/全選向左鈕。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iEPCxITb_mZGUM05_oWw_9nYAmiGbeti4xGivXs6u2UwrKfDCemmwMao0abI31uhMo-mqedD2VoXbJdy4NQpZmuw_j6V1cEhqImoflJBAdLqphcixhxF7JSgOJkap7GPmMjDd8Ot9_0c/&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iEPCxITb_mZGUM05_oWw_9nYAmiGbeti4xGivXs6u2UwrKfDCemmwMao0abI31uhMo-mqedD2VoXbJdy4NQpZmuw_j6V1cEhqImoflJBAdLqphcixhxF7JSgOJkap7GPmMjDd8Ot9_0c/&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iEPCxITb_mZGUM05_oWw_9nYAmiGbeti4xGivXs6u2UwrKfDCemmwMao0abI31uhMo-mqedD2VoXbJdy4NQpZmuw_j6V1cEhqImoflJBAdLqphcixhxF7JSgOJkap7GPmMjDd8Ot9_0c/&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;138&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iEPCxITb_mZGUM05_oWw_9nYAmiGbeti4xGivXs6u2UwrKfDCemmwMao0abI31uhMo-mqedD2VoXbJdy4NQpZmuw_j6V1cEhqImoflJBAdLqphcixhxF7JSgOJkap7GPmMjDd8Ot9_0c/&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Sample.aspx&lt;br /&gt;
&lt;pre class=&quot;brush:xhtml&quot;&gt;&amp;lt;table align=&quot;center&quot; class=&quot;style1&quot; style=&quot;width: 400px&quot;&amp;gt;
    &amp;lt;tr&amp;gt;
        &amp;lt;td align=&quot;left&quot; style=&quot;font-weight: bold; font-size: 13px; font-family: Arial&quot; width=&quot;150px&quot;&amp;gt;
            可選擇的ProductID &amp;lt;/td&amp;gt;
        &amp;lt;td&amp;gt;
            &amp;amp;nbsp; &amp;lt;/td&amp;gt;
        &amp;lt;td align=&quot;left&quot; style=&quot;font-weight: bold; font-size: 13px; font-family: Arial&quot;&amp;gt;
            已選擇的ProductID &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
    &amp;lt;tr&amp;gt;
        &amp;lt;td align=&quot;left&quot;&amp;gt;
            &amp;lt;asp:ListBox ID=&quot;ListBoxLeft&quot; runat=&quot;server&quot; Rows=&quot;5&quot; SelectionMode=&quot;Multiple&quot; Width=&quot;150px&quot;&amp;gt;
                &amp;lt;asp:ListItem&amp;gt;AAAA&amp;lt;/asp:ListItem&amp;gt;
                &amp;lt;asp:ListItem&amp;gt;BBBB&amp;lt;/asp:ListItem&amp;gt;
                &amp;lt;asp:ListItem&amp;gt;CCCC&amp;lt;/asp:ListItem&amp;gt;
                &amp;lt;asp:ListItem&amp;gt;DDDD&amp;lt;/asp:ListItem&amp;gt;
            &amp;lt;/asp:ListBox&amp;gt;
        &amp;lt;/td&amp;gt;
        &amp;lt;td align=&quot;center&quot;&amp;gt;
            &amp;lt;asp:Button ID=&quot;ButtonRight&quot; runat=&quot;server&quot; OnClick=&quot;ButtonRight_Click&quot; Text=&quot;Right&quot;
                Width=&quot;70px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
            &amp;lt;br /&amp;gt;
            &amp;lt;asp:Button ID=&quot;ButtonRightAll&quot; runat=&quot;server&quot; OnClick=&quot;ButtonRightAll_Click&quot; Text=&quot;ALL Right&quot;
                Width=&quot;70px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
            &amp;lt;br /&amp;gt;
            &amp;lt;asp:Button ID=&quot;ButtonLeft&quot; runat=&quot;server&quot; OnClick=&quot;ButtonLeft_Click&quot; Text=&quot;Left&quot;
                Width=&quot;70px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
            &amp;lt;br /&amp;gt;
            &amp;lt;asp:Button ID=&quot;ButtonLeftAll&quot; runat=&quot;server&quot; OnClick=&quot;ButtonLeftAll_Click&quot; Text=&quot;ALL Left&quot;
                Width=&quot;70px&quot; CssClass=&quot;barkbutton&quot; /&amp;gt;
        &amp;lt;/td&amp;gt;
        &amp;lt;td align=&quot;left&quot;&amp;gt;
            &amp;lt;asp:ListBox ID=&quot;ListBoxRight&quot; ondblclick=&quot;__doPostBack(&#39;ButtonLeft&#39;,&#39;&#39;);&quot; runat=&quot;server&quot;
                Rows=&quot;5&quot; SelectionMode=&quot;Multiple&quot; Width=&quot;150px&quot;&amp;gt;&amp;lt;/asp:ListBox&amp;gt;
        &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&lt;/pre&gt;Sample.aspx.cs&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;protected void ButtonRight_Click(object sender, EventArgs e)
    {
        if (ListBoxLeft.SelectedItem != null)
        {
            foreach (ListItem item in ListBoxLeft.Items)
            {
                if (item.Selected == true)
                {
                    ListBoxRight.Items.Add(item);
                }
            }

            foreach (ListItem item in ListBoxRight.Items)
            {
                if (item.Selected == true)
                {
                    ListBoxLeft.Items.Remove(item);
                }
            }
        }

    }

    protected void ButtonRightAll_Click(object sender, EventArgs e)
    {
        foreach (ListItem item in ListBoxLeft.Items)
        {
            ListBoxRight.Items.Add(item);
        }
        ListBoxLeft.Items.Clear();
    }

    protected void ButtonLeft_Click(object sender, EventArgs e)
    {
        if (ListBoxRight.SelectedItem != null)
        {
            foreach (ListItem item in ListBoxRight.Items)
            {
                if (item.Selected == true)
                {
                    ListBoxLeft.Items.Add(item);
                }
            }

            foreach (ListItem item in ListBoxLeft.Items)
            {
                if (item.Selected == true)
                {
                    ListBoxRight.Items.Remove(item);
                }
            }
        }
    }

    protected void ButtonLeftAll_Click(object sender, EventArgs e)
    {
        foreach (ListItem item in ListBoxRight.Items)
        {
            ListBoxLeft.Items.Add(item);
        }
        ListBoxRight.Items.Clear();
    }&amp;nbsp;&lt;/pre&gt;&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html&quot;&gt;[ASP.NET]左右ListBox選單(1) -- 按鈕Trigger&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://wupinny.blogspot.com/2010/05/aspnet-listbox2-javascript-trigger.html&quot;&gt;[ASP.NET]左右ListBox選單(2) -- Javascript Trigger&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http:///#&quot;&gt;[ASP.NET]左右ListBox選單(3) -- 非同步PostBack Trigger &lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/2276809950264324020/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/2276809950264324020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/2276809950264324020'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnetlistbox1-trigger.html' title='[ASP.NET]左右ListBox選單(1) -- 按鈕Trigger'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iEPCxITb_mZGUM05_oWw_9nYAmiGbeti4xGivXs6u2UwrKfDCemmwMao0abI31uhMo-mqedD2VoXbJdy4NQpZmuw_j6V1cEhqImoflJBAdLqphcixhxF7JSgOJkap7GPmMjDd8Ot9_0c/s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-62176858141476971</id><published>2010-05-25T20:08:00.001+08:00</published><updated>2010-05-25T20:08:32.838+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tool"/><title type='text'>Blogger加上表格--放入HTML TABLE</title><content type='html'>在Blogger寫程式分享的文章，若有插入表格的需求，&lt;br /&gt;
表格編寫需要用HTML的方式，如：&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;XXX&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
寫入的原始碼需用CSS的方式包住，才可避免有多餘的空白出現。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&lt;style type=&quot;text/css&quot;&gt;.nobrtable br {display:none}&lt;/style&gt;
&lt;div class=&quot;nobrtable&quot;&gt;
[Table 原始碼]

&lt;/div&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/62176858141476971/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/blogger-html-table.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/62176858141476971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/62176858141476971'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/blogger-html-table.html' title='Blogger加上表格--放入HTML TABLE'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-8186402996992838366</id><published>2010-05-25T20:01:00.004+08:00</published><updated>2010-05-26T22:52:33.359+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>[ASP.NET]LinkButton + Image</title><content type='html'>LinkButton只能秀文字，ImageButton只能秀圖片，&lt;br /&gt;
那當有需求是文字與圖片要一起在同一個按鈕時，目前的解法就是將圖片放入LinkButton中即可。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6V6oBQ38Hvf2N4kB7pwl6O4zf8PwkWiVMB5OqxqeBJme4oXcB44EDiawO4navdbF91OOIEgZAJXs_0_L7yVMgUs00r2J_ejDI1nCSGLRGwwJ_pJOmUONo6h4yef0m2o4UdP9Jb_SrEVKQ/s1600/2010-05-26_083653.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6V6oBQ38Hvf2N4kB7pwl6O4zf8PwkWiVMB5OqxqeBJme4oXcB44EDiawO4navdbF91OOIEgZAJXs_0_L7yVMgUs00r2J_ejDI1nCSGLRGwwJ_pJOmUONo6h4yef0m2o4UdP9Jb_SrEVKQ/s320/2010-05-26_083653.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;asp:LinkButton runat=&quot;server&quot; ID=&quot;LinkButton1&quot; BorderColor=&quot;Gray&quot;
    Font-Names=&quot;Arial&quot; ForeColor=&quot;Navy&quot; BorderWidth=&quot;1px&quot; BackColor=&quot;LightGray&quot;&amp;gt;
    &amp;lt;img src=&quot;images/filter/funnel.png&quot; style=&quot;border:0; vertical-align:bottom&quot; /&amp;gt;Data Filter
&amp;lt;/asp:LinkButton&amp;gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/8186402996992838366/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnet-linkbutton-image.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8186402996992838366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8186402996992838366'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/aspnet-linkbutton-image.html' title='[ASP.NET]LinkButton + Image'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6V6oBQ38Hvf2N4kB7pwl6O4zf8PwkWiVMB5OqxqeBJme4oXcB44EDiawO4navdbF91OOIEgZAJXs_0_L7yVMgUs00r2J_ejDI1nCSGLRGwwJ_pJOmUONo6h4yef0m2o4UdP9Jb_SrEVKQ/s72-c/2010-05-26_083653.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-811296675191230463</id><published>2010-05-13T00:23:00.005+08:00</published><updated>2010-05-25T19:56:20.109+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tool"/><title type='text'>Blogger加上程式碼 -- 高亮度顯示程式(SyntaxHighlighter)</title><content type='html'>在Blogger寫程式分享的文章，必備的套用工具SyntaxHighlighter這類的高亮度顯示程式。&lt;br /&gt;
套用方法：&lt;br /&gt;
&lt;ol&gt;&lt;li&gt; 進入管理介面&lt;b&gt;[&lt;span class=&quot;content&quot;&gt;&lt;/span&gt;版面配置]&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;[修改 HTML] &lt;/b&gt;&lt;/li&gt;
&lt;li&gt;備份範本&lt;b&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;[修改範本&lt;/b&gt;&lt;b&gt;]，&lt;/b&gt;加入以下code至&amp;lt;head&amp;gt;與&amp;lt;/head&amp;gt;之間&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/styles/shCore.css&quot;/&amp;gt;
&amp;lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/styles/shThemeDefault.css&quot; id=&quot;shTheme&quot;/&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shCore.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shLegacy.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushBash.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCpp.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCSharp.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushCss.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushDelphi.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushDiff.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushGroovy.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJava.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushJScript.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPhp.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPlain.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushPython.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushRuby.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushScala.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushSql.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushVb.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://alexgorbatchev.com/pub/sh/2.0.320/scripts/shBrushXml.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&#39;text/javascript&#39;&amp;gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.ClipboardSwf = &#39;http://http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf&#39;;
SyntaxHighlighter.all();
&amp;lt;/script&amp;gt;

&lt;/pre&gt;後續只要在code以&amp;lt;pre class=&quot;brush:xml&quot;&amp;gt;&amp;lt;/pre&amp;gt;框住即可&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;brushes 分類如下：&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
.nobrtable br {display:none}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;nobrtable&quot;&gt;&lt;br /&gt;
&lt;table #a4d1ff=&quot;&quot; bgcolor:=&quot;&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;  &lt;th&gt;Brush name&lt;/th&gt;&lt;th&gt;Brush aliases&lt;/th&gt;&lt;th&gt;File name&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;ActionScript3&lt;/td&gt;&lt;td&gt;as3, actionscript3&lt;/td&gt;&lt;td&gt;shBrushAS3.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;  &lt;td&gt;Bash/shell&lt;/td&gt;&lt;td&gt;bash, shell&lt;/td&gt;&lt;td&gt;shBrushBash.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;ColdFusion&lt;/td&gt;&lt;td&gt;cf, coldfusion&lt;/td&gt;&lt;td&gt;shBrushColdFusion.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;C#&lt;/td&gt;&lt;td&gt;c-sharp,&amp;nbsp;csharp&lt;/td&gt;&lt;td&gt;shBrushCSharp.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;C++&lt;/td&gt;&lt;td&gt;cpp, c&lt;/td&gt;&lt;td&gt;shBrushCpp.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;CSS&lt;/td&gt;&lt;td&gt;css&lt;/td&gt;&lt;td&gt;shBrushCss.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Delphi&lt;/td&gt;&lt;td&gt;delphi, pas, pascal&lt;/td&gt;&lt;td&gt;shBrushDelphi.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Diff&lt;/td&gt;&lt;td&gt;diff, patch&lt;/td&gt;&lt;td&gt;shBrushDiff.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Erlang&lt;/td&gt;&lt;td&gt;erl, erlang&lt;/td&gt;&lt;td&gt;shBrushErlang.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Groovy&lt;/td&gt;&lt;td&gt;groovy&lt;/td&gt;&lt;td&gt;shBrushGroovy.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;JavaScript&lt;/td&gt;&lt;td&gt;js, jscript, javascript&lt;/td&gt;&lt;td&gt;shBrushJScript.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Java&lt;/td&gt;&lt;td&gt;java&lt;/td&gt;&lt;td&gt;shBrushJava.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;JavaFX&lt;/td&gt;&lt;td&gt;jfx, javafx&lt;/td&gt;&lt;td&gt;shBrushJavaFX.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Perl&lt;/td&gt;&lt;td&gt;perl, pl&lt;/td&gt;&lt;td&gt;shBrushPerl.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;PHP&lt;/td&gt;&lt;td&gt;php&lt;/td&gt;&lt;td&gt;shBrushPhp.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Plain Text&lt;/td&gt;&lt;td&gt;plain, text&lt;/td&gt;&lt;td&gt;shBrushPlain.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;PowerShell&lt;/td&gt;&lt;td&gt;ps, powershell&lt;/td&gt;&lt;td&gt;shBrushPowerShell.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Python&lt;/td&gt;&lt;td&gt;py, python&lt;/td&gt;&lt;td&gt;shBrushPython.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Ruby&lt;/td&gt;&lt;td&gt;rails, ror, ruby&lt;/td&gt;&lt;td&gt;shBrushRuby.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Scala&lt;/td&gt;&lt;td&gt;scala&lt;/td&gt;&lt;td&gt;shBrushScala.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;SQL&lt;/td&gt;&lt;td&gt;sql&lt;/td&gt;&lt;td&gt;shBrushSql.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Visual Basic&lt;/td&gt;&lt;td&gt;vb, vbnet&lt;/td&gt;&lt;td&gt;shBrushVb.js&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;XML&lt;/td&gt;&lt;td&gt;xml, xhtml, xslt, html, xhtml&lt;/td&gt;&lt;td&gt;shBrushXml.js&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/811296675191230463/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/blogger-syntaxhighlighter.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/811296675191230463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/811296675191230463'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/blogger-syntaxhighlighter.html' title='Blogger加上程式碼 -- 高亮度顯示程式(SyntaxHighlighter)'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-3327471690249073664</id><published>2010-05-12T23:48:00.011+08:00</published><updated>2010-05-26T23:06:02.462+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="LINQ"/><title type='text'>[Linq]LINQ to Object (ListBox)</title><content type='html'>可複選的ListBox取出被Selected的值。&lt;br /&gt;
解法一：使用LINQ取出Selected == true&lt;br /&gt;
解法二：使用for迴圈尋訪ListBox的每一個ListItem，並判斷ListItem.Selected == true&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iEPCxITb_mZGUM05_oWw_9nYAmiGbeti4xGivXs6u2UwrKfDCemmwMao0abI31uhMo-mqedD2VoXbJdy4NQpZmuw_j6V1cEhqImoflJBAdLqphcixhxF7JSgOJkap7GPmMjDd8Ot9_0c/s1600/2010-05-26_084742.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Sample.aspx&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;asp:ListBox ID=&quot;ListBox1&quot; runat=&quot;server&quot; Rows=&quot;5&quot; SelectionMode=&quot;Multiple&quot; Width=&quot;150px&quot;&amp;gt;
    &amp;lt;asp:ListItem&amp;gt;AAAA&amp;lt;/asp:ListItem&amp;gt;
    &amp;lt;asp:ListItem&amp;gt;BBBB&amp;lt;/asp:ListItem&amp;gt;
    &amp;lt;asp:ListItem&amp;gt;CCCC&amp;lt;/asp:ListItem&amp;gt;
    &amp;lt;asp:ListItem&amp;gt;DDDD&amp;lt;/asp:ListItem&amp;gt;
&amp;lt;/asp:ListBox&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;解法一：&lt;/b&gt;&lt;/div&gt;Sample.aspx.cs&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;var selItems = from ListItem li in ListBox1.Items
                   where li.Selected == true
                   select li.Text;

    Response.Write(&quot;Selected Item(s): &quot;);
    foreach (var item in selItems)
    {
        Response.Write(item.ToString() + &quot;&quot;);
    }

&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;解法二：&lt;/b&gt;&lt;/div&gt;Sample.aspx.cs&lt;br /&gt;
&lt;pre class=&quot;brush:c-sharp&quot;&gt;ListBox1.SelectionMode = ListSelectionMode.Multiple;
    for (int i = 0; i &amp;lt; ListBox1.Items.Count; i++)
    {
        if(ListBox1.Items[i].Selected == true)
        {
           Response.Write( ListBox1.Items[i].ToString() + &quot;&quot;); 
        }
    }
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/3327471690249073664/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/linqlinq-to-object-listbox.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/3327471690249073664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/3327471690249073664'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/linqlinq-to-object-listbox.html' title='[Linq]LINQ to Object (ListBox)'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-4971904954124092183</id><published>2010-05-11T23:02:00.031+08:00</published><updated>2010-05-26T22:58:21.322+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="LINQ"/><title type='text'>[Linq]LINQ to DataSet</title><content type='html'>針對DataTable的資料，若有加工或篩選的需求，Linq 是目前我選用要熟悉的技術。&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/zh-tw/library/bb552415%28v=VS.90%29.aspx&quot;&gt;LINQ to DataSet 中的查詢&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
其中範例中，大致分成兩種，一為查詢運算式語法，二為以方法為基礎的查詢語法&lt;br /&gt;
其實對我而言，就是一個有from，另一個沒有~&lt;br /&gt;
當我遇到要做Order By時，似乎只有看到有from那種語法有範例。&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;color: blue;&quot;&gt;&lt;b&gt;查詢運算式語法&lt;/b&gt;&lt;/div&gt;&lt;pre class=&quot;brush: c-sharp&quot;&gt;DataTable products = ds.Tables[&quot;Product&quot;];

IEnumerable&amp;lt;datarow&amp;gt; query =
    from product in products.AsEnumerable()
    select product;

Console.WriteLine(&quot;Product Names:&quot;);
foreach (DataRow p in query)
{
    Console.WriteLine(p.Field&amp;lt;string&amp;gt;(&quot;Name&quot;));
}&lt;/pre&gt;&lt;pre class=&quot;brush: c-sharp&quot;&gt;DataTable products = ds.Tables[&quot;Product&quot;];

IEnumerable&amp;lt;datarow&amp;gt; query =
    from product in products.AsEnumerable()
    orderby product.Field&amp;lt;decimal&amp;gt;(&quot;ListPrice&quot;) descending
    select product;

// Force immediate execution of the query.
IEnumerable&amp;lt;datarow&amp;gt; productsArray = query.ToArray();

Console.WriteLine(&quot;Every price from highest to lowest:&quot;);
foreach (DataRow prod in productsArray)
{
    Console.WriteLine(prod.Field&amp;lt;decimal&amp;gt;(&quot;ListPrice&quot;));
}
&lt;/pre&gt;&lt;div style=&quot;color: blue;&quot;&gt;&lt;b&gt;以方法為基礎的查詢語法&lt;/b&gt;&lt;/div&gt;&lt;pre class=&quot;brush: c-sharp&quot;&gt;DataTable products = ds.Tables[&quot;Product&quot;];

var query = products.AsEnumerable().
    Select(product =&amp;gt; new
    {
        ProductName = product.Field&amp;lt;string&amp;gt;(&quot;Name&quot;),
        ProductNumber = product.Field&amp;lt;string&amp;gt;(&quot;ProductNumber&quot;),
        Price = product.Field&amp;lt;decimal&amp;gt;(&quot;ListPrice&quot;)
    });

Console.WriteLine(&quot;Product Info:&quot;);
foreach (var productInfo in query)
{
    Console.WriteLine(&quot;Product name: {0} Product number: {1} List price: ${2} &quot;,
        productInfo.ProductName, productInfo.ProductNumber, productInfo.Price);
}&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/4971904954124092183/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/05/linqlinq-to-dataset.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/4971904954124092183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/4971904954124092183'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/05/linqlinq-to-dataset.html' title='[Linq]LINQ to DataSet'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-3837490751789388452</id><published>2010-01-25T22:24:00.002+08:00</published><updated>2010-01-25T22:28:55.657+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="PL/SQL"/><title type='text'>[Oracle]PL/SQL與T-SQL的語法比較文件</title><content type='html'>今日從企圖找出PL/SQL中continue的相似語法，無意間找到了一份PL/SQL與T-SQL的語法用法比較的word文件。也同時也試用google共用文件的功能。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.google.com/View?id=drj5cdm_1497sz5vf4&quot;&gt;PL/SQL與T-SQL比較Word文件&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
稍後讀完文件後，再做補充說明吧~~今天雖然是文章發表日，就讓我先偷懶一下下吧!!!</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/3837490751789388452/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/01/oracleplsqlt-sql.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/3837490751789388452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/3837490751789388452'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/01/oracleplsqlt-sql.html' title='[Oracle]PL/SQL與T-SQL的語法比較文件'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-8805670016337677757</id><published>2010-01-20T11:09:00.002+08:00</published><updated>2010-05-12T07:48:16.515+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Date"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="To_Char"/><title type='text'>[Oracle]Week的時間區間</title><content type='html'>日前有一個需求為呈現從今日往前推53週的日期，列出每週的週別與開始與結束日期。每週的開始日期為週二。&lt;br /&gt;
&lt;br /&gt;
呈現如下： &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRsyyWLBD730WeXHGpcuiLUGH7I57zISKW4mCMxc4Ki2cmm7-dzHtjsZdyhNVsJXQBuJ9lxaaD37Gym-QroUh1GHV7yHEAdmqhVfhyDVFc8x_5OERUhq75c_gUEh3vZLDVYpZ-JH7K2iri/s1600-h/weekno.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRsyyWLBD730WeXHGpcuiLUGH7I57zISKW4mCMxc4Ki2cmm7-dzHtjsZdyhNVsJXQBuJ9lxaaD37Gym-QroUh1GHV7yHEAdmqhVfhyDVFc8x_5OERUhq75c_gUEh3vZLDVYpZ-JH7K2iri/s400/weekno.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;解法一：&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select to_char(start_date, &#39;iyyy&#39;) || &#39;W&#39; || to_char(start_date, &#39;iw&#39;) week_no,
       to_char(start_date, &#39;yyyy/mm/dd&#39;) start_date,
       to_char(end_date, &#39;yyyy/mm/dd&#39;) end_date
  from (select next_day(sysdate, 3) - rn * 7 start_date,
               (next_day(sysdate, 3) - (rn - 1) * 7) - 1 end_date
          from (select rownum rn from dual connect by level &amp;lt;= 53))&amp;nbsp;&lt;/pre&gt;重點說明：&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;使用connect by level &amp;lt;= 53 去生出53筆資料 ，rownum依序呈現1,2,3,4....等數據。&lt;/li&gt;
&lt;li&gt;使用next_day去指定週二為一週的起始日期。&lt;/li&gt;
&lt;li&gt;使用to_char()參數選用iyyy與iw去指定使用iso的週別定義方式轉換週別。&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/8805670016337677757/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/01/oracleweek.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8805670016337677757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/8805670016337677757'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/01/oracleweek.html' title='[Oracle]Week的時間區間'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRsyyWLBD730WeXHGpcuiLUGH7I57zISKW4mCMxc4Ki2cmm7-dzHtjsZdyhNVsJXQBuJ9lxaaD37Gym-QroUh1GHV7yHEAdmqhVfhyDVFc8x_5OERUhq75c_gUEh3vZLDVYpZ-JH7K2iri/s72-c/weekno.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-5745182909546409474</id><published>2010-01-11T22:40:00.002+08:00</published><updated>2010-05-12T07:47:51.501+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coalesce"/><category scheme="http://www.blogger.com/atom/ns#" term="Group By"/><category scheme="http://www.blogger.com/atom/ns#" term="NVL"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><title type='text'>[Oracle]Mutil Row To One Row應用(二)</title><content type='html'>本次範例應用北風資料For Oracle中&lt;b&gt; orders &lt;/b&gt;的訂單資料Table做為Sample。本次範例想要取得訂單資料中每天訂單中每個貨運公司的最大運費，並且有優先次序的選擇呈現貨運公司的資料，例如：如果當天有托運公司1,2,3呈現資料的次序為&lt;b&gt;1 &amp;gt; 2 &amp;gt; 3&lt;/b&gt; 。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select orderid, orderdate, shipvia, freight from orders t
&lt;/pre&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdeDYeZf_JWW7KgskrVl4ezaFuyCh2Xcc5xonExJsxEZSxNW14lSQzLdcmpHDJ5hAlaNHegA79aoyoCgZN_R-zkrvjNEiFZOi7OAu5_K4cAAJ6gDdodcVXJOfuf5UO7P0Qiy0vfCweBha3/s1600-h/order1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdeDYeZf_JWW7KgskrVl4ezaFuyCh2Xcc5xonExJsxEZSxNW14lSQzLdcmpHDJ5hAlaNHegA79aoyoCgZN_R-zkrvjNEiFZOi7OAu5_K4cAAJ6gDdodcVXJOfuf5UO7P0Qiy0vfCweBha3/s320/order1.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
結果如下：&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3dCpS6m63svlXq7u1vbrsewrp6vw5DAh_ZxpFaw_UkYfFI-eZC_eZ15N97MKTWdlzjhbNGrpruJkzrSPNLL4ZuyGLQiFmCAtBhc-y6lhMySil6iIdAjhfL8uMJAtdxj8WV46bYERO9esG/s1600-h/order2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3dCpS6m63svlXq7u1vbrsewrp6vw5DAh_ZxpFaw_UkYfFI-eZC_eZ15N97MKTWdlzjhbNGrpruJkzrSPNLL4ZuyGLQiFmCAtBhc-y6lhMySil6iIdAjhfL8uMJAtdxj8WV46bYERO9esG/s320/order2.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;解法一：&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select orderdate,
       shippers,
       coalesce(shippers1_freight, shippers2_freight, shippers3_freight) shippers_freight
  from (select orderdate,
               min(shipvia) shippers,
               max(decode(shipvia, 1, freight)) shippers1_freight,
               max(decode(shipvia, 2, freight)) shippers2_freight,
               max(decode(shipvia, 3, freight)) shippers3_freight
          from (select to_char(t.orderdate, &#39;yyyy/mm/dd&#39;) orderdate,
                       shipvia,
                       max(t.freight) freight
                  from orders t
                 group by to_char(t.orderdate, &#39;yyyy/mm/dd&#39;), shipvia)
         group by orderdate
         order by orderdate)
&lt;/pre&gt;&lt;br /&gt;
接著就要把SQL分三層一一抽絲剝繭，想當然爾的從最內層開始解說：&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&amp;nbsp;group by to_char(t.orderdate, &#39;yyyy/mm/dd&#39;), shipvia -- 依據每日每個貨運公司取得最大運費 max(t.freight)。&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Mutil Row To One Row：利用group搭配max函數與decode將三個貨運公司分列為三個欄位。&lt;/li&gt;
&lt;li&gt;&amp;nbsp;利用&lt;b&gt;coalesce&lt;/b&gt;函數依優先次數呈現貨運公司的運費。&lt;/li&gt;
&lt;/ol&gt;[註] ：&lt;a href=&quot;http://www.techonthenet.com/oracle/functions/coalesce.php&quot;&gt;coalesce&lt;/a&gt; 為&lt;a href=&quot;http://www.techonthenet.com/oracle/functions/nvl.php&quot;&gt; nvl&lt;/a&gt; 的加強版。&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nvl( string1, string2 ) =&amp;gt;判斷 string1 如果為 null 則呈現 string2。nvl 無法應付兩個以上null的判斷。&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coalesce(string1, string2, string3) =&amp;gt;判斷 string1 為null則呈現 string2，若 string2&amp;nbsp; 也是null則呈現 string3。&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/5745182909546409474/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/01/oraclemutil-row-to-one-row.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/5745182909546409474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/5745182909546409474'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/01/oraclemutil-row-to-one-row.html' title='[Oracle]Mutil Row To One Row應用(二)'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdeDYeZf_JWW7KgskrVl4ezaFuyCh2Xcc5xonExJsxEZSxNW14lSQzLdcmpHDJ5hAlaNHegA79aoyoCgZN_R-zkrvjNEiFZOi7OAu5_K4cAAJ6gDdodcVXJOfuf5UO7P0Qiy0vfCweBha3/s72-c/order1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-7989588991696023070</id><published>2010-01-04T22:46:00.000+08:00</published><updated>2010-01-04T22:46:17.849+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="PL/SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Tool"/><title type='text'>[Oracle]PL/SQL Developer Tool</title><content type='html'>提到Oracle的相關開發工具，就非得提到我每天都一定會使用的&lt;a href=&quot;http://www.allroundautomations.com/bodyplsqldev.html&quot;&gt;PL/SQL Developer&lt;/a&gt;，用他來做什麼呢??&lt;br /&gt;
&lt;br /&gt;
當然不外乎就是寫SQL Statement，會用到就是&lt;a href=&quot;http://www.allroundautomations.com/plssql.html&quot;&gt;SQL Window&lt;/a&gt; ，同一個SQL Window裡面可以下多個Statement，只要用分號隔開，SQL Window下方的結果集就會依照Statement順序分頁籤。&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;SQL Window：&lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt;(File -&amp;gt; New -&amp;gt; SQL Window)&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.allroundautomations.com/images/plssql.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;390&quot; src=&quot;http://www.allroundautomations.com/images/plssql.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
撰寫PL/SQL更是好用的工具，這時候用到就是&lt;a href=&quot;http://www.allroundautomations.com/plseditor.html&quot;&gt;Program Window&lt;/a&gt;，我常用來撰寫Procedure,Function與Package，撰寫PL/SQL的會有Code Assistant，例如在cursor後&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-color: #ffd966; color: red;&quot;&gt; . &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;就會帶出相關的欄位，大大的提升寫程式的速度與正確性。&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: red;&quot;&gt;Program Window：&lt;/b&gt; &lt;span style=&quot;color: black;&quot;&gt;(File -&amp;gt; New -&amp;gt; Program Window)&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.allroundautomations.com/images/plseditor.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;416&quot; src=&quot;http://www.allroundautomations.com/images/plseditor.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
寫完Program總要試跑看看，這時候就一定要介紹&lt;a href=&quot;http://www.allroundautomations.com/plsdebugger.html&quot;&gt;Test Window&lt;/a&gt;了，執行Test Window前先在Program Window設定中斷點，然後就可以一步一步的Debug了，當然可以設定查看變數，又有另一個頁籤可以查看dbms_output.put_line的結果，Debug利用這個工具可謂是相當完整了。&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Test Window：&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt;(File -&amp;gt; New -&amp;gt; Test Window)&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.allroundautomations.com/images/plsdebugger.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;426&quot; src=&quot;http://www.allroundautomations.com/images/plsdebugger.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
另外有一個一定要介紹的就是&lt;a href=&quot;http://www.allroundautomations.com/plsbeautifier.html&quot;&gt;PL/SQL Beautifier&lt;/a&gt;，只要SQL或是PL/SQL寫的正確，寫的再醜的格式都一定會幫你排的漂漂亮亮的，如果排的格式不是你預期的，還使用    PL/SQL Beautifier Option去設定自己喜愛的格式。&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: red;&quot;&gt;PL/SQL Beautifier&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;：&lt;/span&gt;&lt;/b&gt;(Edit -&amp;gt; PL/SQL Beautifier)&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.allroundautomations.com/images/plsbeautifier.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;498&quot; src=&quot;http://www.allroundautomations.com/images/plsbeautifier.gif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
以上圖片皆引用於&lt;a href=&quot;http://www.allroundautomations.com/&quot;&gt;http://www.allroundautomations.com&lt;/a&gt;，其他項目請參閱&lt;a href=&quot;http://www.allroundautomations.com/bodyplsqldev.html&quot;&gt;http://www.allroundautomations.com/bodyplsqldev.html&lt;/a&gt;。&lt;br /&gt;
&lt;br /&gt;
接下來介紹我喜歡的Layout，如果畫面內一塊一塊的功能視窗不小心按掉了，可以進入Tools中的第三個Section勾勾看囉~ Layout調整完就可以使用(Window -&amp;gt; Save Layout)將畫面配置儲存。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWrY8HDD79cA8z2nqoQpLA9dx8AJqYohiC1mAsmhsZxZdqa8j91ozR8qIJQ6H-b82XO_be1rdvBFsO398C4K-_yLAuXr7S1tBF_muOCJijoON-xBWunjvzAeE36YkzOCidAPsB34lWLoYD/s1600-h/plsql.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWrY8HDD79cA8z2nqoQpLA9dx8AJqYohiC1mAsmhsZxZdqa8j91ozR8qIJQ6H-b82XO_be1rdvBFsO398C4K-_yLAuXr7S1tBF_muOCJijoON-xBWunjvzAeE36YkzOCidAPsB34lWLoYD/s640/plsql.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/7989588991696023070/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2010/01/oracleplsql-developer-tool.html#comment-form' title='2 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/7989588991696023070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/7989588991696023070'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2010/01/oracleplsql-developer-tool.html' title='[Oracle]PL/SQL Developer Tool'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWrY8HDD79cA8z2nqoQpLA9dx8AJqYohiC1mAsmhsZxZdqa8j91ozR8qIJQ6H-b82XO_be1rdvBFsO398C4K-_yLAuXr7S1tBF_muOCJijoON-xBWunjvzAeE36YkzOCidAPsB34lWLoYD/s72-c/plsql.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-642925678148471869</id><published>2009-12-23T21:33:00.006+08:00</published><updated>2010-05-12T07:48:53.633+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Join"/><category scheme="http://www.blogger.com/atom/ns#" term="Mod"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><title type='text'>[Oracle]Mutil Row To One Row應用(一)</title><content type='html'>我有一張Log Table，會紀錄著procedure開始執行與結束的時間，該Log Table的紀錄方式為procedure Begin時寫入一筆資料，procedure End時寫入一筆資料，所以每次procedure執行只要是成功的狀態，就會有雙雙成對的Begin/End的資料，我期許可以算出每次procedure執行所需要的時間，於是就有把每兩筆Log Data變成一筆後去做時間運算的需求。&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select * from log_table t
&lt;/pre&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU1KnB4_ypDHeqQDBUTqqEI1AMabPzQEQRbQfumzlucb6zHelcfjFv1kGFvVytrqJmfGxBmL1QSIrSvjh48VMtvipUq-jA40cJy9OZg7rikOeW7JGHiR70PXQz5Q_qFtiDnCMGqMO7WDXQ/s1600-h/log_table.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU1KnB4_ypDHeqQDBUTqqEI1AMabPzQEQRbQfumzlucb6zHelcfjFv1kGFvVytrqJmfGxBmL1QSIrSvjh48VMtvipUq-jA40cJy9OZg7rikOeW7JGHiR70PXQz5Q_qFtiDnCMGqMO7WDXQ/s320/log_table.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA7QXieH_8XRznjZ-TO9CuSknaSg4aquB4nR9voUusrbraoMnrqhp7zJ7lqHxN5OuWO_YO0kBdyVqMPbrlGvnrt7dWUGOZaBKKk0Pm3FU_0-AC1-QhNYyY-HxXLF4X5kwEiBoeYbKlkK2W/s1600-h/log_table2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA7QXieH_8XRznjZ-TO9CuSknaSg4aquB4nR9voUusrbraoMnrqhp7zJ7lqHxN5OuWO_YO0kBdyVqMPbrlGvnrt7dWUGOZaBKKk0Pm3FU_0-AC1-QhNYyY-HxXLF4X5kwEiBoeYbKlkK2W/s320/log_table2.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
呈現上圖結果，利用兩個欄位相減去運算出每次Loader所執行花費的時間。&lt;br /&gt;
&lt;br /&gt;
以上這個題目拋出請同事們一起動動腦，加上我個人的解法共募集了三種解法。&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;解法一：&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select a.execute_time begin_time,
       b.execute_time end_time,
       round((b.execute_time - a.execute_time) * 24 * 60, 2) cost_time
  from (select rownum begin_rn, execute_time
          from (select *
                  from log_table t
                 where t.procedure_name = &#39;Loader1&#39;
                   and t.code = &#39;Begin&#39;
                 order by t.execute_time)) a,
       (select rownum end_rn, execute_time
          from (select *
                  from log_table t
                 where t.procedure_name = &#39;Loader1&#39;
                   and t.code = &#39;End&#39;
                 order by t.execute_time)) b
 where a.begin_rn = b.end_rn

&lt;/pre&gt;上列解法一運用兩份sub query的join去做資料結合，&lt;br /&gt;
將Begin的sub query與End的sub query 利用rownum來join。 &lt;br /&gt;
&lt;br /&gt;
不過解法一對log_table做了兩次資料處理，在大量資料的狀況下，想必效能應該會稍差。&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;解法二：&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select max(decode(code, &#39;Begin&#39;, execute_time)) begin_date,
       max(decode(code, &#39;End&#39;, execute_time)) end_date,
       round((max(decode(code, &#39;End&#39;, execute_time)) -
             max(decode(code, &#39;Begin&#39;, execute_time))) * 24 * 60,
             2) cost_time
  from (select rn,
               mod(rn, 2) rn_1,
               ceil(rn / 2) rn_2,
               b.code,
               b.execute_time
          from (select rownum rn, a.code, a.execute_time
                  from (select *
                          from log_table t
                         where t.procedure_name = &#39;Loader1&#39;
                         order by t.execute_time) a) b)
 group by rn_2
&lt;/pre&gt;上列解法二運用rownum的數學運算後，再執行group by去做資料結合，&lt;br /&gt;
先利用rownum將每一筆資料依照時間排序編列流水號，&lt;br /&gt;
mod為取餘數，目前在分組運算中並沒利用到，&lt;br /&gt;
ceil為無條件進入，解法二中就是將每一筆資料除以2後取無條件進入，這樣就將每兩筆變成兩兩一組，有同樣的編號(rn_2)，&lt;br /&gt;
當我們已經順利的將資料分成兩兩一組後，再利用group by rn_2，搭配decode與群組函數max就可以轉秩資料(row to column)。&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;解法三：&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select b.begin_time,
       b.end_time,
       round((b.end_time - b.begin_time) * 24 * 60, 2) cost_time
  from (select a.*, rownum rn
          from (select t.execute_time begin_time,
                       lead(execute_time, 1) over(ORDER BY execute_time) AS end_time
                  from log_table t
                 where t.procedure_name = &#39;Loader1&#39;
                 order by t.execute_time) a) b
 where mod(rn, 2) = 1
&lt;/pre&gt;解法三主要是應用oracle特有的function lead去做資料結合，&lt;br /&gt;
lead主要是把每一筆資料的下一筆資料的某的欄位抓上去擺在隔壁當鄰居欄位，&lt;br /&gt;
所以在a的sub query中Begin的execute_time就會有一個鄰居欄位為End 的execute_time&lt;br /&gt;
當然End 的execute_time也會出現一個鄰居欄位為Begin的execute_time，&lt;br /&gt;
所以我們就應用解法二裡面的mod餘數，只去取Begin的那一筆來計算，Begin那筆的rownum 取2的餘數都是1，End那筆的rownum可被2整除，所以餘數都是0。&lt;br /&gt;
&lt;br /&gt;
解法二、三針對來源Table:log_table都只做一次資料處理，所以可想而知的效能應該會比較好才是，相關那個解法的效能較佳，數據會說話，等我的後續報導啦~~</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/642925678148471869/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2009/12/oraclemutil-row-to-one-row.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/642925678148471869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/642925678148471869'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2009/12/oraclemutil-row-to-one-row.html' title='[Oracle]Mutil Row To One Row應用(一)'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU1KnB4_ypDHeqQDBUTqqEI1AMabPzQEQRbQfumzlucb6zHelcfjFv1kGFvVytrqJmfGxBmL1QSIrSvjh48VMtvipUq-jA40cJy9OZg7rikOeW7JGHiR70PXQz5Q_qFtiDnCMGqMO7WDXQ/s72-c/log_table.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-760857978822291431</id><published>2009-12-07T23:02:00.009+08:00</published><updated>2010-05-12T07:47:10.531+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><title type='text'>[Oracle]無中生有的月曆</title><content type='html'>本日課題是無中生有的產出一個月份天數的筆數，並且在今天的日期標示Today的字串於第二個欄位。&lt;br /&gt;
&lt;br /&gt;
第一種解法為利用Oracle內建的all_object的sys table去做無中生有的筆數生成。&lt;br /&gt;
第二種解法是同事爬出文來的，用於沒有all_object的select的權限時，利用connect by level去生成所需筆數 。&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWZPkHNXouIKXj7FgR_it4YqGoD_KXgBfhFr6a93vIux6wmJHZACvmUegab-W_wrO3wWkTwONmXgvlL1x79cdrg9bTcbNJAKtgaUwhE7QI4mG50cbn6s4zAXqLwDQ5ere_pbX-CfcTCfOV/s1600-h/calendar.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWZPkHNXouIKXj7FgR_it4YqGoD_KXgBfhFr6a93vIux6wmJHZACvmUegab-W_wrO3wWkTwONmXgvlL1x79cdrg9bTcbNJAKtgaUwhE7QI4mG50cbn6s4zAXqLwDQ5ere_pbX-CfcTCfOV/s320/calendar.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;解法一：&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select trunc(sysdate, &#39;MM&#39;) + rn - 1 Calendar,
       decode(trunc(sysdate, &#39;MM&#39;) + rn - 1, trunc(sysdate, &#39;DD&#39;), &#39;Today&#39;) high_Today
  from (select rownum rn
          from all_objects t
         where rownum &amp;lt;=
               trunc(LAST_DAY(sysdate), &#39;DD&#39;) - trunc(sysdate, &#39;MM&#39;) + 1)
&lt;/pre&gt;&lt;div style=&quot;color: red;&quot;&gt;&lt;b&gt;解法二：&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select trunc(sysdate, &#39;MM&#39;) + rn - 1 Calendar,
       decode(trunc(sysdate, &#39;MM&#39;) + rn - 1, trunc(sysdate, &#39;DD&#39;), &#39;Today&#39;) high_Today
  from (select rownum rn
          FROM dual
        CONNECT BY LEVEL &amp;lt;=
                   trunc(LAST_DAY(sysdate), &#39;DD&#39;) - trunc(sysdate, &#39;MM&#39;) + 1)
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;connect by&lt;/b&gt;&amp;nbsp; 為階層相關的函數，詳細Functon使用可看&lt;a href=&quot;http://www.psoug.org/reference/connectby.html&quot;&gt;Link&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/760857978822291431/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2009/12/oracle.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/760857978822291431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/760857978822291431'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2009/12/oracle.html' title='[Oracle]無中生有的月曆'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWZPkHNXouIKXj7FgR_it4YqGoD_KXgBfhFr6a93vIux6wmJHZACvmUegab-W_wrO3wWkTwONmXgvlL1x79cdrg9bTcbNJAKtgaUwhE7QI4mG50cbn6s4zAXqLwDQ5ere_pbX-CfcTCfOV/s72-c/calendar.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1529398903068091023.post-1980887671697793498</id><published>2009-11-18T00:02:00.004+08:00</published><updated>2010-05-12T07:46:50.306+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Not"/><category scheme="http://www.blogger.com/atom/ns#" term="Oracle"/><title type='text'>[Oracle]Not 的妙用</title><content type='html'>最近遇到了一個需求，讓我驚覺Not 的妙用~~&lt;br /&gt;
&lt;br /&gt;
欄位一等於A，且欄位二等於B，不列入計算&lt;br /&gt;
欄位一等於A，且欄位二等於C，不列入計算&lt;br /&gt;
&lt;br /&gt;
這個看似簡單的條件，可讓我小小思考了一下，才寫出自己滿意的寫法。 &lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt; 以employees table為範例，假設條件為呈現所有 employees的資料，但濾除以下兩個條件：&lt;br /&gt;
&lt;br /&gt;
job_id = SA_REP 且&amp;nbsp; manager_id = 145&lt;br /&gt;
&lt;br /&gt;
job_id = SA_REP 且&amp;nbsp; manager_id = 146&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: red;&quot;&gt;解法一： &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select *
  from employees t
 where not (t.job_id = &#39;SA_REP&#39; and t.manager_id in (145, 146));
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;解法二：&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select *
  from employees t
 where not exists (select &#39;X&#39;
          from employees
         where t.job_id = &#39;SA_REP&#39;
           and t.manager_id in (145, 146));
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;解法三：&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select *
  from employees t
 where (t.job_id, t.manager_id) not in (select &#39;SA_REP&#39;, 145 from dual)
   and (t.job_id, t.manager_id) not in (select &#39;SA_REP&#39;, 146 from dual);
&lt;/pre&gt;&lt;br /&gt;
&lt;b style=&quot;color: red;&quot;&gt;解法四：&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot; name=&quot;code&quot;&gt;select *
  from employees t
 where (t.job_id, t.manager_id) not in
       (select &#39;SA_REP&#39;, 145
          from dual
        union
        select &#39;SA_REP&#39;, 146 from dual)
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://wupinny.blogspot.com/feeds/1980887671697793498/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://wupinny.blogspot.com/2009/11/oraclenot.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/1980887671697793498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1529398903068091023/posts/default/1980887671697793498'/><link rel='alternate' type='text/html' href='http://wupinny.blogspot.com/2009/11/oraclenot.html' title='[Oracle]Not 的妙用'/><author><name>吳皮尼</name><uri>http://www.blogger.com/profile/00001893416779601316</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>