Google Search

自訂搜尋

2009年3月31日 星期二

[APEX] 讀書心得 - Part I (Application Builder Concepts)

花了三天時間終於完成了第一個應用系統, 內含收貨資料維護, 出貨資料維護和出貨庫存報表. 其中出貨資料維護是用 Master-Detail的 Form去設計. 使用後的感覺是, Schema也就是Table/Index/...的建立還是要透過APEX的畫面自行設計&建立, 懂關聯式資料的人都可以上手. 之後進到WEB畫面的建構部份才是真正的挑戰. 如前文所提, 我也K了不少文件和安裝範例程式來看, 總算完成第一個應用程式(正請老婆大人驗收中).
感覺是APEX的底層設計考慮不少Layer的觀念很像Java 的 MVC(Model & View & Control)觀念, 所以有些設定要想一下他的原理才能夠瞭解, 知道如何修改.
下面是我K了官網上的文件後, 先將整個WEB產生的架構整理如下, 看一下在去K厚厚的原文書會比較有幫助.







.

Item #ItemSub ItemDescription

.

1.1PagePage"the basic building block of an application,contain user interface elements, such as tabs, lists, buttons, items, and regions."

.

1.2PagePage Rendering"lists user interface controls and logic that are executed when a page is rendered. Page Rendering is the process of generating a page from the database
Show Page is the page rendering process. It assembles all the page attributes (including regions, items, and buttons) into a viewable HTML page."

.

1.3PagePage Processing"Lists logic controls (such as computations and processes) that are evaluated and executed when the page is processed.
Accept Page performs page processing. It performs any computations, validations, processes, and branching.
When you request a page using a URL, the engine is running Show Page. When you submit a page, the Application Express engine is running Accept Page or performing page processing during which it saves the submitted values in the session cache and then performs any computations, validations, or processes."

.

1.4ConditionConditionA small unit of logic that helps you control the display of regions, items, buttons, and tabs as well as the execution of processes, computations, and validations.

.

1.4.1Condition TypeCurrent page in Expression 1"3,100,203
If the current page is 100, then this condition evaluates to true and the condition passes."

.

1.4.2Condition TypeExists (SQL query returns at least one row)"SELECT 1 FROM employees WHERE department_id = :P101_DEPTNO"

.

1.4.3Condition TypePL/SQL ExpressionNVL(:MY_ITEM,'NO') = 'YES'

.

1.5Session State ManagementSessionA session is a logical construct that establishes persistence (or stateful behavior) across page views

.

1.5.1Session State ManagementReferencing Session State"1. SQL --> :MY_ITEM --> Standard bind variable syntax for items whose names are no longer than 30 characters. Use this syntax for references within a SQL query and within PL/SQL.
2. PL/SQL --> V('MY_ITEM') --> PL/SQL syntax referencing the item value using the V function.
3. PL/SQL --> NV('MY_NUMERIC_ITEM') --> Standard PL/SQL syntax referencing the numeric item value using the NV function.
4. Static text (exact) --> &MY_ITEM. --> Static text. Exact substitution."

.

1.5.2Session State ManagementSetting Session StateWhen a user submits a page, the Application Express engine automatically stores values typed into fields (items) in session state.

.

1.5.3Session State ManagementClearing Session State"Uses standard f?p syntax to clear the cache
1. Clearing Cache by Item
2. Clearing Cache by Page
3. Clearing Cache for an Entire Application
4. Clearing Cache for the Current User Session"

.

1.6Understanding URL SyntaxUnderstanding URL Syntax"The URL that displays for each page identifies the location of Oracle Application Express, the address of Oracle Application Express, the application ID, the page number, and the session ID.
Using f?p Syntax:
f?p=App:Page:Session:Request:Debug:ClearCache:itemNames:itemValues:PrinterFriendly

.

1.7Substitution StringsSubstitution Strings"You can use substitution strings within a page template or region source to replace a character string with another value. As you design your application and enable users to edit items, you use substitution strings to pass information.
You can use substitution strings in Application Builder in the following ways:
* Include a substitution string within a template to reference component values
* Reference page or application items using &ITEM. syntax
* Use built-in substitution strings to achieve a specific type of functionality

.






2009年3月28日 星期六

[APEX] 學習計畫

就在找到APEX的免費開發平台後, 下一步當然是要趕快上手. 第一個目標是幫老婆的網拍事業建立一套簡單的進銷存的管理系統, 也讓身為大股東的我知道到底老婆賺了多少錢. 下面是我目前計畫中的學習來源

1. APEX 原文書
  • Pro Oracle Application Express : 這本比較進階比較適合有點觀念或開APEX發經驗. 小道消息是這本書去對岸的網站搜尋一下應該找得到PDF版本, 不過有幫助還是買原版吧.
2. APEX 官網文件

下面是官網上提供的文件, 應該是很完整啦!
==============================================================
3.2 Release Notes HTML PDF
Installation Guide HTML PDF
2 Day + Developer's Guide HTML PDF
Application Builder User's Guide HTML PDF
Migration Guide HTML PDF
Administration Guide HTML PDF
SQL Workshop and Utilities Guide HTML PDF
API Reference HTML PDF
Advanced Tutorials HTML PDF
Full Library HTML














============================================================

3. 部落格
當今學東東當然要上BLOG, 而且用Goolge Reader看更是方便. 直接到官網下載OPML檔案後
再import進 Google Reader. 就有一堆看不完的文章可供參考.

4. 官網的SAMPLE 應用程式
官網裡有提供一些現成的應用程式, 像是Asset management, Issue Tracker等. 下載下來後, 只要Import進去開發平台後, 就可以從實際的例子了解是如何做設定. 值得一提的是從官網下載下來的就是一個.SQL檔案, 代表說真正Import進去的就是一堆設定而已, 而沒有程式碼.

好啦! 我的進銷存的進貨以完成, 銷貨還進行中. 因為對APEX的一些細部設定掌握度不高常常會卡住. 不過等熟悉後, RAD(Rapid Application Development)的好處就會顯現出來, 不用寫程式就可以開發出WEB系統, 酷吧!!!

2009年3月26日 星期四

[APEX] APEX 免費應用開發平台

就在對APEX做了一番研究之後, 卻苦無開發平台(我家裡的NB有裝 Oracle XE & APEX, 但是想要用還要動一些手腳有點小麻煩)可供發揮. 這時發現原來 Oracle 有提供一個平台供開發人員在上面開發程式, 建立 Table等等. 開發出來的應用程式也可以供其他人使用. 但是因為它的目的是為了推廣APEX所以不允許在上面存放重要資料, 當然會有一些Quota的限制. Oracle可以這樣做一個重要的原因是因為它整個開發介面都是架構在WEB上的.

為了使用這個平台, 可以先下以下網址(http://apex.oracle.com/i/index.html), 申請一個帳號, 還要經過Oracle審核後發MAIL通知密碼後幾可使用. 應該是真的會審核吧! 因為一開始申請完等半天都收不到MAIL,大概過了兩天後才收到含密碼的MAIL,還以為是MAIL出問題. 下面就是都入的首頁畫面.

哈哈! 可以上工啦! 不管在哪裡都可以開發系統而且好了以後還可以秀給朋友看看! 不錯吧!

趕緊一起來試試這個RAD(Rapid Application Development)的好咚咚吧!


2009年3月19日 星期四

[Content Management] Oracle Content Service Study

最近公司的年度計畫之一談到的是客戶服務的加強,但幾位客服同仁們好像也想不到什麼好主意. 畢竟這個艱困的年代,留住客戶是第一要事. 就在這時撇見競爭對手的網站上,既然搶先一步提供了Oracle iFS的服務. 突然想起進來幾家客戶都有類似的需求,就是提供檔案的分享服務. 也就是不要透過傳統的MAIL或是FTP共享空間的方式來作為協同合作的文件交換平台.

這時就想到我們家也有機會導入Oracle iFS來加強客戶服務提升溝通效率. Oracle iFS 到了10G已經被整合成了Oracle Collaborative Suite(協同作業),旗下包含了
  • Oracle Content Services:Oracle 內容服務是Oracle 協同作業中文件檔案和內容管理套件.
  • Oracle Mail:Oracle 郵件通過將所有消息(包括電子郵件、語音郵件和傳真)存儲在單一的Oracle10g 資料庫中,提供了一個真正統一的企業訊息傳遞基礎架構.
  • Oracle Calendar:Oracle 日曆為現代企業而開發功能強大的時間管理產品.
  • Oracle Discussions:Oracle 討論區使得使用者方便張貼有關某個具體主題的訊息和問題,共享其答案和意見.
  • Oracle Real Time Collaboration:Oracle 網路會議立即線上會議搭配會議白板更可將所有會議紀錄錄音錄影,成為日後最佳教育訓練方式.
  • Oracle Messenger:Oracle 即時訊息 (企業內部資訊傳達更容易及更安全).
  • Oracle Workspaces:Oracle 工作區使用者可共享文件檔案、保存討論、管理會議和任務.
重點回到 Oracle Content Service, 前身是iFS. 其實說穿了就是BLOB,沒記錯BLOB就是將檔案儲存在Database裡面(檔案儲存在Database裡面對查詢和管理當然有很大的幫助),再透過Oracle Application Server將檔案透過WEB和類似檔案總管的型態呈現給使用者. 這中間當然要有很好的權限管理機制,加上檔案版本的管理(Check In/Out). 透過這樣的機制,傳統上的MAIL和FTP的溝通平台應當會有很大的改善. 好啦!趕快去KK文件和邀幾家Vendor來Survey看看是否真得可行吧!

2009年3月17日 星期二

[APEX] 安裝 APEX 3.2 in Oracle 10g XE

APEX(Oracle Application Express)是Oracle用來取代Oracle Form和HTML DB的下一世代產品,他是架構在Meta-Data上面的開發架構,簡單的說,Oracle試著讓你不要寫程式也可以快速開發出一些實用的WEB應用程式,也稱為宣告式開發(Declarative Programming).

APEX 官方網站
http://www.oracle.com/technology/products/database/application_express/index.html

下面是來自Oracle官方對APEX的簡單介紹.
=========================================
Oracle Application Express (Oracle APEX), formerly called HTML DB, is a rapid web application development tool for the Oracle database. Using only a web browser and limited programming experience, you can develop and deploy professional applications that are both fast and secure. Oracle application express combines the qualities of a personal database, productivity, ease of use, and flexibility with the qualities of an enterprise database, security, integrity, scalability, availability and built for the web. Application Express is a tool to build web-based applications and the application development environment is also conveniently web-based. Watch this Application Express Positioning flash demonstration and then try Application Express simply by signing up for an account at apex.oracle.com.
=========================================


我的Laptop上已經有Oracle 10G XE,APEX3.2也在日前Release,今天花了點時間把APEX安裝起來,順道在APEX官上網下載了資產管理的範例,也安裝起來,執行的結果如下圖. 之後就可透過APEX提供的功能去修改功能,或新增報表,不用再寫程式喔!


APEX我還不太熟,用這個當起點學學,未來有機會在來Share. 據說著名的Oracle Asktom網站也是用APEX開發的,個人覺得挺有未來空間的.

2009年3月13日 星期五

[EDW] Enterprise Data warehouse - Star Schema

Enterprise Data Warehouse的架構中,Star schema是最常使用的Schema設計概念, 又稱為Dimensional Modeling. 它的精神就是將商業流程用一個一個星星(STAR)去代表,舉例而言,STAR像是營收,但看營收又會根據月份,產品別等維度來看. 維度就是Dimension. 所以Star Schema的設計就是透過分析商業流程將ERP, MES等前端系統的資料將其轉置為Fact和Dimension Table. 後續在做資料呈現時,不論是WEB或其他報表工具,透過Star transformation從ORACLE擷取資料,這也是ORACLE官方建議的作法. 這裡就談一下Star Schema這個概念,主要是從以下書籍(data warehouse design solution)和WIKI而來.

定義

Star schema 由 WIKI-fact tables (通常只有一個) 和其引用到的多個 WIKI-dimension tables所組成.

運作模式

談Data warehouse常常會和OLTP系統相比較. 所謂OLTP就是由一系列的Event和Transactions所組成配合OLTP正規化的基本設計精神. OLTP正規化的目的是確保資料的一致性和減少資料重複儲存. 但是在這個架構之下,當要回答前述如二月份某產品的營收有多少時?OLTP系統通常無法快速提供答案,原因也正如前所述,因為正規化,一個如上簡單的問題對OLTP系統可能要下一個SQL連接五六個Table. 正因為這樣的問題,Star Schema孕育而生.

以上為例,營收資料在Star Schema中就叫Measure, Measure可能包含營收金額,出貨數量,毛利率,發票號碼等,而擺放Measure的Table就叫Fact Table. 而這些Measure如何被商業人員查詢,查詢的進入點就叫Dimension. Dimension可能包含出口國家,產品別,銷售客戶,銷售日期等等.

EDW設計人員在將商業流程分析後,產生所謂的Measure和Dimension後,進入Table設計階段. 如以下的一個STAR範例.



Fact Table除了包含主要Measure資料外,還會有包含連接到Dimension Table的Foreign Key. 而Dimension Table則由Dimension key(Primary Key)和屬性(Attribute)所組成.

如這個例子,Fact是 由Measure-Unit_Sold和三個Dimension Key(Store_ID,Product_ID,Date_ID)所組成. 而每個dimension table都有一個 primary key和相關的屬性,如日期,週別,商店州別等等屬性. 所以當要查詢某品牌某商店的賣出數量時,使用以下SQL可以得到答案.

        =================================================
SELECT
P.Brand,S.Country, SUM (F.Units_Sold)
FROM Fact_Sales F INNER JOIN Dim_Date D ON F.Date_Id = D.Id
INNER JOIN Dim_Store S ON F.Store_Id = S.Id
INNER JOIN Dim_Product P ON F.Product_Id = P.Id
WHERE D.Year = 1997
AND P.Product_Category = 'tv'
GROUP BY P.Brand, S.Country;
===================================================

Fact Table
在設計Fact Table時要特別注意的是所謂的細度(Grain),所謂細度就是Fact Table中的每一筆
記錄,都擁有一樣的細度. 以上面的例子而言,Fact Table的每一筆資料都屬於同一張發票項目
(Item). 這個意義代表前端ERP系統的發票項目一定是同一Store,Date和Product,如此資料才能
被正確從ERP轉換至EDW,EDW也才能正確呈現資料.

Dimension Table
如前所述,Dimension Table由Dimension Key和 Dimension Attributes所組成. 作者特別強調在
這裡要儘量避免將Table作正規化,因為一旦做正規化,查詢效能會大受影響.

MDB
Star Schema通常發生在關連式資料庫中,但也有像Business Object, Hyperion, Teradata等廠
商有他們自己專用的多維度資料庫(MultiDimensional Database),又稱為Cube. 這些Cube搭配
這些廠商專用的資料呈現軟體, 通常可以很快速的將資料呈現出來,而且還可以做類似EXCEL的
樞紐分析. 但是也有限制,就是資料量的大小有限制. 這也是將Star Schema推導在關連式資料
庫的目的去移除資料量的限制.

下文再看看更多Fact/Dimension Table設計的技巧.

2009年3月7日 星期六

[SQL Tune] 評估 Index 存取方式(Access Methods)

Index 的建立不論是B-tree, Bitmap還是 function-based index, 都是加快資料存取的手法. 簡單的說, Index 有點像是建立資料的捷徑, 而這個捷徑就是RowID.所以 Index存取的目的就是去蒐集RowID, 藉此捷徑快速的取得資料.

常見的Index存取有以下幾個方式

  • Index Range Scan
    這是最常見的存取方式, 從以下SQL可以清楚瞭解.

    select
    employee_name
    from employee
    where Birth_date >sysdate-100;


    Birth_date這個欄位若有建立Index, Oracle透過 B-Tree Index 找到Rowid後, 即可快速找到資料.

  • Fast Full-index Scan
    Full index scan 乍聽之下會不清楚Oracle在搞甚麼? 和 Full Table Scan有何不同? 其實是因為有些SQL只需要Index的資料根本不需要碰到 Table的資料, 像 Count(*), 如以下SQL.

    select distinct country, count(*)
    from employee
    group by country;

    如同 Full-Table Scan, Fast Full-Index Scan也會參考 db_file_multiblock_read_count的參數. 也就是當Fast Full-Index Scan發生時, Oracle也會一次根據此參數設定讀取多個Block.至於 Oracle 是否執行 Fast Full-Index Scan, 前提是 所有在 select 和 where中指定的欄位都 必須存在於 Index中.另外必須有多於 10%回傳的資料是位於Index中, Optimizer才會選擇使 用. 也可以用這個 Hint(/*+ index_ffs() /*)去強迫 Oracle執行Fast Full-Index Scan.
  • Index Full Scan
    通常發生在Optimizer認為SQL回傳的結果會按照Index排序,也就是有 'Order By'的指令. 它會用 Temp space料對Index做排序. 和 Fast Full-Index Scan不同的是, Fast Full-Index Scan是對整個Index做Scan並不會做排序. Index Full Scan使用的是DB Sequential Read而Fast Full-Index Scan使用的是DB Scattered Read.
參考資料
http://www.oracle-training.cc/oracle_tips_index_access.htm
http://www.dbanotes.net/Oracle/Index_full_scan_vs_index_fast_full_scan.htm

2009年3月4日 星期三

[ERP] SAP- 不景氣時代,IT價值的提昇- 心得

2/26有幸參加SAP研討會 "不景氣時代,IT價值的提昇心得", 不景氣年代談的東西當然要和不景氣有點關係. 以下是一些心得報告.
  • SAP 將它本身複雜到連SAP Sales都有點困惑的產品版本整合成 Business Suite 7.0, 包含ERP, PLM(Product Lifecycle Management),CRM(Customer Relation Management),SCM(Supply Chain Management)和 SRM(Supplier Relation Management), 整個架構整合在 NetWeaver的平台上. 另外在SAP在併購 BI 產品 Business Object後也將其整合成 Business Information Platform, 涵跨EPM(Enterprise Performance Management).
  • Business Suite 7.0有一個模組是 GTS (Global Trade Service) 就是有關進出口保稅相關的功能. 這一部分多數台灣導SAP的客戶應該都是採外部系統或SAP外掛方式處理, SAP現在終於有方案, 只是不知是否合適台灣環境.
  • SAP CRM 強調的是使用的方便性和百分之百的WEB介面.
  • SAP 電子簽核方案, 目的在減少紙本簽核和加強簽核效率. 此功能整合了 Interactive Adobe form, 也就是可以離線簽核. 好處在於, 一些食古不化的高階主管, 電子簽核系統在強大, 就是不願意上系統簽核, 一定要看到紙本. 這時可以使用Interactive Adobe form, 讓他有用紙本簽核的感覺, Review完後, 按下PDF上的Submit, 資料可以透過 Netweaver更新回SAP. 在SAP做電子簽核有一個好處就是減少系統間的介面, 因為多數企業資料還是置於ERP內部. 這對IT人員可說是一大福音, 減少很多介面維護的問題.當然SAP令人望之生畏的License收費, 可能會讓很多人對這個東西打退堂鼓.
  • SAP在使用者介面上除了傳統的SAP GUI, WEB的介面也為人熟知, 另外就是Mobile的介面, 看來也做得不錯.
  • 這次主要想聽的是SRM但是著墨不多有點小失望.
看看SAP的這些功能, SAP應該花了不少銀兩在研發這些產品上, 雖然SAP主力還是在ERP, 後續這些ERP以外的功能在台灣推展的情況有待觀察. 企業界對在整合性(Total SAP Solution)和成本考量(High license fee)兩個端點間要好如何拿捏, 是一門學問.