Tuesday, May 26, 2009

ORA-01720: grant option does not exist for 'XXX'

今天因為程式需求,需要做一件看起來很詭異的事情。大概是這樣:
情境1:
資料庫裡有A跟F兩個使用者。A使用者下有一個table: B。我要在F使用者下新建一個view: B,內容跟A(user)的B(table)完全一樣。
到目前為止其實還好。就是先grant select B(table)的權限給F(user)即可成功的建起view B。

情境2: (問題在這)
這個F(user)下的B(view)是什麼用途呢~? 是要給A(user)用的XD。所以我說這是件詭異的事情,自己有資料不用,偏偏要去用別人的XD(特殊需求特殊需求~)。
照說如果A(user)要可以select F(user)下的B(view),那也應該做跟上面一樣的事情: grant select B(view)的權限給A(user)。
就在這個moment!! 如果這麼做,就會收到如標題那樣的錯誤訊息。

至於為什麼呢? 這樣說好了,我今天答應A給他"參考"我的作業,如果A沒經過我的同意,又把我的作業給C看,那算什麼!!! 分數三等份阿!!! 怎麼行呢? XD

假如我答應借A看我的作業的同時,也說: "去散播我的愛吧~"(就是你可以自行把我的東西在借給下個人),那樣就不會有問題。所以回到資料庫上也一樣。在授權給F(user)的時候,必須准許他也可以授權給別人:
SQL> grant select on A.B to F with grant option;

that's all!! 這樣F(user)的B(view)也就能再做授權給別人的動作了(即使那個人是A)。

寫完還要檢查一下那些A阿F阿B阿table阿view阿有沒有搞錯=   = 小複雜

Thursday, May 21, 2009

Linq #1: Getting Started

這兩天花了一點時間大概看了一些What is Linq? Linq's design goal. Why Linq? History等不是很想看的東西。
With LINQ, Microsoft's intention was to provide a solution for the problem of object-relational mapping, as well as to simplify the interaction between objects and data sources.

這是我唯幾有畫的段落=    =,不知道究竟是不是個key。還是比較想來體驗一下code。
跟hello world一樣,首先要來個hello linq:


   1:  using System;

   2:  using System.Linq;

   3:   

   4:  static class HelloWorld

   5:  {

   6:    static void Main()

   7:    {

   8:      //先來個collection

   9:      string[] words = 

  10:         { "hello", "wonderful", "linq", "beautiful", "world" };

  11:      

  12:      //傳說中的linq語法在這from~ where~ select

  13:      var shortWords =   

  14:        from word in words

  15:        where word.Length <= 5

  16:        select word;

  17:   

  18:      //把剛剛處理好的資料印出來,結果就是: hello linq world 各一行

  19:      foreach (var word in shortWords)

  20:        Console.WriteLine(word);

  21:    }

  22:  }


Linq特別強調data query不再只是一串string,他變成是程式的一部份,所以你不會在執行程式時才發現sql下錯了、字拼錯、參數名字打錯這類的錯誤。Linq背後可存取的資料來源很多種,不管是存取資料庫或只是一個collection,只要學了Linq,就可以用統一的方法對這些資料來源進行存取。

再來一段長一點的,下面要表達的是,Linq也可以把資料弄成XML的樣子,重點是: 輕易地


   1:  using System;

   2:  using System.Linq;

   3:  using System.Xml;

   4:  using System.Xml.Linq;

   5:   

   6:  class Book

   7:  {

   8:    public string Publisher;

   9:    public string Title;

  10:    public int    Year;

  11:    public Book(string title, string publisher, int year)

  12:    {

  13:      Title = title;

  14:      Publisher = publisher;

  15:      Year = year;

  16:    }

  17:  }

  18:   

  19:  static class HelloLinqToXml

  20:  {

  21:    static void Main()

  22:    {

  23:        //用上面那個book class產生3筆資料

  24:        Book[] books = new Book[] {             

  25:        new Book("Ajax in Action", "Manning", 2005),

  26:        new Book("Windows Forms in Action", "Manning", 2006),

  27:        new Book("RSS and Atom in Action", "Manning", 2006)

  28:        };

  29:   

  30:      //重頭戲: 只能意會不能言傳XD

  31:      XElement xml = new XElement("books",  // layer1

  32:        from book in books

  33:        where book.Year == 2006

  34:        select new XElement("book",  //layer2

  35:          new XAttribute("title", book.Title),  // attribute of book(layer2)

  36:          new XElement("publisher", book.Publisher)  //layer3

  37:        )

  38:      );

  39:      Console.WriteLine(xml);

  40:   

  41:      //result:

  42:   

  43:          //<books>                                     ==> layer1

  44:          //  <book title="Windows Forms in Action">    ==> layer2 with attribute(title)

  45:          //    <publisher>Manning</publisher>          ==> layer3

  46:          //  </book>

  47:          //  <book title="RSS and Atom in Action">

  48:          //    <publisher>Manning</publisher>

  49:          //  </book>

  50:          //</books>

  51:    }

  52:  }


接下來應該是最常應用的: 連接資料庫


   1:  using System;

   2:  using System.Linq;

   3:  using System.Data.Linq;

   4:  using System.Data.Linq.Mapping;

   5:   

   6:  static class HelloLinqToSql

   7:  {

   8:     //declaring the classes to represent the application data: entities

   9:     //mapping object and database by adding customer attritube

  10:    [Table(Name="Contacts")]

  11:    class Contact

  12:    {

  13:      [Column(IsPrimaryKey=true)]

  14:      public int ContactID { get; set; }

  15:      [Column(Name="ContactName")]

  16:      public string Name { get; set; }

  17:      [Column]

  18:      public string City { get; set; }

  19:    }

  20:   

  21:    static void Main()

  22:    {

  23:      string path =   //使用northwind資料庫

  24:        System.IO.Path.GetFullPath(@"..\..\Data\northwnd.mdf");

  25:      //translate requests for objects into SQL queries

  26:      DataContext db = new DataContext(path);

  27:   

  28:      var contacts =                     

  29:        from contact in db.GetTable<Contact>()

  30:        where contact.City == "Paris"

  31:        select contact;

  32:   

  33:      foreach (var contact in contacts)        

  34:        Console.WriteLine("Bonjour "+contact.Name);

  35:    }

  36:  }


完畢。上面那一段程式,Linq做掉了一些東西:
  1. 連接資料庫
  2. 自動轉換SQL query
  3. 執行SQL

....如此一般如此一般.... 他其實還是有點複雜的...

Tuesday, May 19, 2009

Load report failed: The maximum report processing jobs limit

今天使用者在測試系統上反應了這個問題,
中文的訊息是: 已經到達您系統管理員所設定的最大報表處理工作限制
英文的訊息是: The maximum report processing jobs limit configured by your system administrator has been reached.

看見這個錯誤訊息之後,我第一個反應是跑去server把IIS裡這個網站的應用程式集區回收、重新啟動就好了。

事後才來查詢原因。首先發現原來.Net裡每張報表可跑的次數是有預設上限的(75)。
這個數字可以在註冊表裡找到:
BusinessObjects Enterprise XI Release 2 
---------------------------------------------
HKEY_LOCAL_MACHINE\SOFTWARE\BUSINESS OBJECTS\SUITE 11.5\REPORT APPLICATION SERVER\SERVER\PrintJobLimit

BusinessObjects Enterprise XI
----------------------------------
HKEY_LOCAL_MACHINE\SOFTWARE\BUSINESS OBJECTS\SUITE 11.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit

Crystal Enterprise 10
------------------------
HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit

是可以上修啦,不過用量真的大的話,依然會發生一樣的事情。
最好還是在page_unload()事件裡把報表Dispose掉~ 應該算一勞永逸吧!!

除了剛剛那個連結有人提到,下面這個也是。


User Account Control(UAC) in Vista

先貼後整理

Wednesday, May 13, 2009

C#.NET2008 connect Oracle9i

Error Message: System.Data.OracleClient 需有 Oracle 用戶端軟體版本 8.1.7 或以上版本
這個錯誤訊息看得我真是無敵錯愕!!! 因為在這之前我OEM用得好好的,SQL Plus照樣跑的嚇嚇叫。
這樣顯眼的錯誤訊息辨識度一定很高,我預期他不難找,但是解法眾說紛紜。
  1. 首先,有可能你的電腦真的沒有裝Oracle Client,那就來HERE下載並裝他。
    檔案都大的要命請不要拼命下載。只需要(92010NT_CLT.zip)即可。
    Oracle9i Database Release 2 Client for Microsoft Windows 98/2000/NT/XP
  2. 因為我確定自己有裝client所以另一個經實驗證明可信度較高的做法是:
    NETWORK SERVICE存取oracle安裝目錄的權限。
  3. (補)最重要!!! 重開機!!!
就這樣,that's all.
Monday, May 11, 2009

Issue about the runaway temporary tablespace of Oracle

三個禮拜前注意到oracle下某個user的temp tablespace空間成長到一個驚人的數字去了,才開始看相關的資訊。會注意到這個也都拜每個禮拜的排程備份所賜,排程備份把temp tablespace也都加了進去,26G的備份導致時間拖得很長,進一步影響到其他oracle相關的排程,於是這個temp tablespace暴肥的事實就這樣忽然跑了出來XD。
  1. 首先要知道的,就是這個temporary tablespace是做什麼用的,竟然比資料檔還要龐大。以下是眾多資料中最clear且easy的說明(不過我看他的年份也最舊...):
    Temporary tablespaces are used to manage space for database sort operations and for storing global temporary tables. For example, if you join two large tables, and Oracle cannot do the sort in memory (see SORT_AREA_SIZE initialisation parameter), space will be allocated in a temporary tablespace for doing the sort operation. Other SQL operations that might require disk sorting are: CREATE INDEX, ANALYZE, Select DISTINCT, ORDER BY, GROUP BY, UNION, INTERSECT, MINUS, Sort-Merge joins, etc.

  2. 接著,temporary tablespace看來只是暫時替代記憶體用的,真的需要備份嗎? oracle的文件裡其實就滿明確的說: You should not back up temporary tablespaces.
    But why??
    TEMPFILEs are not recorded in the database's control file. This implies that one can just recreate them whenever you restore the database, or after deleting them by accident.

  3. 最後,來個新的tempfile吧,以下是我在production直接玩的(不要命XD),跟我看到的所有文件不太一樣,待會再說說。
    3.1. 直接利用UI介面在該temporary tablespace新增一個tempfile,設定好大小、autoextend的大小等
    3.2. 把舊的tempfile drop掉:

    SQL> alter database tempfile 'oradata/[db_name]/[file_name]' drop;
  4. 觀察一陣子在手動把原本龐大的tempfile delete掉吧~
我說大部份人的做法,都是先create另一個tablespace,把user的temp tablespace轉到新的tablespace上,接著砍掉舊的tempfile重新指定好後,再把user的temp tablespace轉回來,最後砍掉新增的tablespace...

我真的還不確定我那種直接來的方法會不會有影響,可是目前觀察起來是好的,到底會不會有問題呢=      =

Tuesday, May 05, 2009

Oracle SQL Developer UI problem

花俏如我,每使用一個軟體一定要先變變他的長相。就在某天我意外發現sqldeveloper竟然也可以換換衣服時,我下手了,在經過提示須要重新啟動才可以套用新設定之後,他就壞了= =。
所謂的壞了,是當你再次開啟sqldeveloper時,可以看到一開始logo的進度,跑完後,就沒下文了。可是去看task manager又有sqldeveloper.exe在跑,整個就有一種沒救了的感覺,只好開始找問題找論壇。
Luckly!!!在OTN上面看到有人做了跟我完全一樣的動作,就遇到一樣的問題XD,非常開心。
先說說我的環境: winXP SP3 + sqldeveloper 1.5.4 + jdk6 upd10
跟OTN上問問題的人不太一樣,不過實驗證明,解法一樣可行。
1. 首先問題就是出在去動UI風格,而相關的config記錄在product-preferences.xml這個檔案裡。
2. 這個檔案的路徑在 C:\Documents and Settings\[user_name]\Application Data\SQL Developer\system1.5.4.59.40\o.sqldeveloper.11.1.1.59.40\
那些版本的數字可能會有些不同。
3. 在

<hash n="environment-options">
區段裡記錄著外觀風格的設定,預設有這兩行

<value n="lafClass" v="oracle.bali.ewt.olaf2.OracleLookAndFeel">
<value n="lafThemeClass" v="skin:fusionblue">

如果手賤把風格改為XP什麼鬼的,就會變成這樣:

<value n="lafClass" v="com.sun.java.swing.plaf.windows.WindowsLookAndFeel">
<value n="lafThemeClass" v="">

然後sqldeveloper就開不起來了...
4. 改回去吧,就可以用了。

Ref: OTN
Friday, May 01, 2009

Diana Krall - Look Of Love



The look of love is in your eyes
A look your smile can't disguise
The look of love is saying so much more than just words could ever say
And what my heart has heard, well it takes my breath away

I can hardly wait to hold you, feel my arms around you
How long I have waited
Waited just to love you, now that I have found you

You've got the
Look of love, it's on your face
A look that time can't erase
Be mine tonight, let this be just the start of so many nights like this
Let's take a lover's vow and then seal it with a kiss

I can hardly wait to hold you, feel my arms around you
How long I have waited
Waited just to love you, now that I have found you
Don't ever go
Don't ever go
I love you so

Tags