PostRank

2009/08/21

如何自動清理File Server Public過期文件

1.安裝Microsoft的工具 Robocopy

 

2.製作批次文件(clear_XXX_public.bat),以XXX為例。
a.
先於 \\192.168.5.250\資訊部Public\Temp下建立當天日期的資料夾
@mkdir z:\temp\%date:~0,4%%date:~5,2%%date:~8,2%

 

b.robocopy工具,將w:\(192.168.5.250\XXX Public)中,超過35天的文件,以搬移的方式移到步驟a.建立的資料夾中,並填寫搬移記錄於 z:\temp\clear_XXX_public_20090821.log
@robocopy w:\ z:\temp\%date:~0,4%%date:~5,2%%date:~8,2% /s *.* /maxage:999 /minage:35 /move /v /fp /DCOPY:T /TS /tee /log:z:\temp\clear_XXX_public_%date:~0,4%%date:~5,2%%date:~8,2%.log

 

3.Windows的排定的工作,設定每天0點自動執行clear_XXX_public.bat

2009/08/20

如何設定 SQL Server 使用超過 2 GB 的實體記憶體

如何設定 SQL Server 使用超過 2 GB 的實體記憶體

SQL Server 2000 Enterprise 和 SQL Server 2000 Developer Editions 都可以使用下列選項:
‧ 使用 Boot.ini 的 /PAE 參數和 SQL Server 的 AWE 啟用選項,可以讓 SQL Server 2000 使用超過 4 GB 的記憶體。如果沒有使用 /PAE 參數,則 SQL Server 最多只能使用 3 GB 記憶體。

注意 如果要讓 AWE 在 Windows 2000 Data Center 中能夠使用 16 GB 以上的記憶體範圍,請確定 Boot.ini 檔案中沒有 /3GB 參數。如果在 Boot.ini 檔案中有 /3GB 參數,Windows 2000 可能就無法正確定址 16 GB 以上的任何記憶體。

當您在 32 GB 系統上配置 SQL Server AWE 記憶體時,Windows 2000 可能需要至少 1 GB 記憶體來管理 AWE。

下列範例顯示如何啟用 AWE 以及如何為 [最大伺服器記憶體] 選項設定 6 GB 的限制:

sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'awe enabled', 1
RECONFIGURE
GO
sp_configure 'max server memory', 6144
RECONFIGURE
GO

 

32bit OS 的只能定址到 4GB 的實體記憶體,這也是為什麼當你實體記憶體超過 4GB 時預設是無法使用 4GB 以上的實體記憶體(因為定址不到)。Intel 在 Pentium Pro 後加上了 PAE(Physical Address Extension) 增加 4bit 來讓定址能到 32GB。所以以你的例子來說要在 boot.ini 中加上 /PAE 參處才能定址到所有的記憶體。

Windows 所有作業系統開啟 PAE 後支援的最大實際記憶體容量如下表所示: 

作業系統 支援 PAE 後的最大記憶體容量

Windows 2000 Advanced Server

8 GB 的實體 RAM

Windows 2000 Datacenter Server

32 GB 的實體 RAM

Windows XP (所有版本)

4 GB 的實體 RAM*

Windows Server 2003 (and SP1) Standard Edition

4 GB 的實體 RAM*

Windows Server 2003 Enterprise Edition

32 GB 的實體 RAM

Windows Server 2003 Datacenter Edition

64 GB 的實體 RAM

Windows Server 2003 SP1 Enterprise Edition

64 GB 的實體 RAM

Windows Server 2003 SP1 Datacenter Edition

128 GB 的實體 RAM


/3GB 參數與實體記憶體無關,就算你實體記憶體只有 2G 或更少也可以開啟 3GB 參數。這個參數影響的是每個應用程式能定址到的記憶體容量。32Bit 應用程式啟動的時候都是直接給他 4GB 的空間。預設值是 App 2GB/ System 2GB,透過 /3GB 參數可以把分配改成 App 3GB/System 1GB。當然分配歸分配,你的應用程式使用到的記憶體才會被分配,這時候可以分配到實體的記憶體位置,也可以分配到虛擬記憶體上(Pagefile)。所以如果你沒有開啟 3GB 參數,當你的應用程式要使用超過 2GB 的記憶體時,系統會告訴他 Out of Memory,即使你實體記憶體有 8GB 也沒用。
當您的應用程式會使用超過 2GB 的話還能夠繼續抓到記憶體就表示你的 3GB 設定生效了。當然如果您的應用程式需要的記憶體不只 3GB,您就必須要使用 AWE 方式來使用超過 3GB 的記憶體。
 
/PAE  是 IA32 處理器新增的功能,可以定址 4 GB 以上的實體記憶體。下列作業系統可以使用 PAE 利用超過 4 GB 的實體記憶體:
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Datacenter Server
  • Microsoft Windows Server 2003 Enterprise Edition
  • Microsoft Windows Server 2003 Datacenter Edition
如果要啟用 PAE,請使用 Boot.ini 檔案中的 /PAE 參數。
 
AWE (Address Windowing Extensions) 允許 32 位元的作業系統存取大量的記憶體。AWE 是由作業系統所公開,而且在 Microsoft Windows 2000 Server 與 Windows Server 2003 中的實作方式稍微不同。AWE 是使用 awe enabled 選項 所啟用的。
 

詳細資訊,請參閱< 管理大型資料庫的記憶體>。

在 Windows Server 2003 上,SQL Server 支援 AWE 記憶體的動態配置。在啟動期間,SQL Server 只保留一小部分的 AWE 對應記憶體。如果需要額外的 AWE 對應記憶體,作業系統會將它動態配置到 SQL Server。同樣地,如果需要較少的資源,SQL Server 可以將 AWE 對應記憶體傳回作業系統,供其他處理序或應用程式使用。如需有關 awe enabled 組態選項的詳細資訊,請參閱< awe enabled 選項>。

在 Windows Server 2003 系列之後,已增加了可支援的實體記憶體量。AWE 可存取的實體記憶體將視您使用的作業系統而有所不同。下列清單中提供每個 Windows Server 2003 作業系統在寫入時,可以存取的實體記憶體上限。

  • Windows Server 2003 Standard Edition 最高支援 4 GB 的實體記憶體。
  • Windows Server 2003 Enterprise Edition 最高支援 32 GB 的實體記憶體。
  • Windows Server 2003 Datacenter Edition 最高支援 64 GB 的實體記憶體。

設定記憶體選項

搭配任何 Windows Server 2003 作業系統版本執行時,SQL Server 會動態配置 AWE 對應記憶體。換句話說,緩衝集區可以動態管理 AWE 對應記憶體 (在 min server memory max server memory 選項的條件約束內),以平衡與整體系統需求搭配使用的 SQL Server 記憶體。

啟用 AWE 時,SQL Server 一定會嘗試使用 AWE 對應記憶體。這個動作會套用至所有記憶體組態,包括設定為提供小於 3 GB 使用者模式位址空間給應用程式的電腦。

簡單來說是

  • /PAE 是給作業系統用的,目的是要存取超過 4GB 的實體記憶體
  • /3GB 是給應用程式用的,目的是要讓應用程式可以使用超過 2GB 的記憶體(最大 3GB)。例如 Exchange Server
  • 如果您的應用程式需要超過 3GB 的記憶體,您要使用 AWE(Address Windows Extension)才能使用超過 3GB 的記憶體。例如 SQL Server

 

參考資料:

 
 

如何編輯 Boot.ini 檔案,以添加 /3GB /PAE參數

如果要檢視及編輯 Boot.ini 檔案,請依照下列步驟執行:
  1. 按一下 [開始],指向 [設定],然後按一下 [控制台]
  2. 在 [控制台] 中,按兩下 [系統]
  3. 按一下 [進階] 索引標籤,然後按一下 [啟動及修復] 下的 [設定]
  4.  [系統啟動] 下方,按一下 [編輯]
注意:在多重開機作業系統設定中,藉由在 [預設作業系統] 清單中按一下所需的作業系統,以選取要啟動的預設作業系統。

2009/08/18

如何使用ROBOCOPY.exe (XP Resource Kit/Standard Vista command)

Robocopy GUI Download the code for this article: UtilitySpotlight2006_11.exe (1052KB)

Syntax
      ROBOCOPY source_folder destination_folder [file(s)_to_copy] [options]
 
Key
   file(s)_to_copy : A list of files or a wildcard.
                          (defaults to copying *.*)
 
  Source options
                /S : Copy Subfolders                                          /s表示包括除空檔下的所有子目錄,如果沒有則僅複製指定目錄下的檔而不包括子目錄
                /E : Copy Subfolders, including Empty Subfolders.            /e表示複製所有子目錄包括空檔夾
 /COPY:copyflag[s] : What to COPY (default is /COPY:DAT). /copy默認參數datsou比如:/copy:datsou(也可以用/copyall),表示將所有原始檔案夾的資訊複製到目標檔夾中 
                      (copyflags : D=Data, A=Attributes, T=Timestamps).     D=檔資料,A=檔屬性,T=時間資訊 
                      (S=Security=NTFS ACLs, O=Owner info, U=aUditing info). S=許可權資訊,O=所有者資訊,U=審核資訊
              /SEC : Copy files with SECurity (equivalent to /COPY:DATS).   /sec表示copy檔並帶安全屬性資訊,等同於/copy:dats
          /DCOPY:T : Copy Directory Timestamps. ##
          /COPYALL : Copy ALL file info (equivalent to /COPY:DATSOU).       /copyall等同於/copy:datsou
           /NOCOPY : Copy NO file info (useful with /PURGE).                 /nocopy表示copy檔不附帶任何屬性資訊
 
                /A : Copy only files with the Archive attribute set. /a表示只copy存檔屬性的檔,/m表示將只具有存檔屬性的檔拷貝到目標盤後,將拷貝生成的檔的存檔屬性去掉。
                /M : like /A, but remove Archive attribute from source files.
            /LEV:n : Only copy the top n LEVels of the source tree.         /lev:n表示複製的層級,比如指定層級後c:\windows\temp(二級)下的檔會被複製,而c:\windows\temp\downloads(三級)下的檔則不被複製
 
         /MAXAGE:n : MAXimum file AGE - exclude files older than n days/date/maxage:n表示最遠修改時間的檔,修改時間比這個還要舊的檔將不會被複製。
         /MINAGE:n : MINimum file AGE - exclude files newer than n days/date. /minage,表示最近修改時間,比這個時間新的檔將不被複製。
                     (If n < 1900 then n = no of days, else n = YYYYMMDD date).
/maxage:後可接數位,也可以接日期,數位小於1900時表 示天數,否則就得用YYYYMMDD來表示具體的日期,如/maxage:20070110表示2007110後被修改的檔才允許複製。與之相對 應的參數是
 
              /FFT : Assume FAT File Times (2-second date/time granularity).
              /256 : Turn off very long path (> 256 characters) support.
 
   Copy options
                /L : List only - don't copy, timestamp or delete any files.
              /MOV : MOVe files (delete from source after copying).          /mov表示當從原始檔案移動到目的地以後,將原始檔案刪除,只作用於檔,不作用於目錄。
             /MOVE : Move files and dirs (delete from source after copying)./move表示把原始檔案和目錄結構都移動到目的地,源位置檔和目錄結構都會被刪除,起剪貼作用
 
                /Z : Copy files in restartable mode (survive network glitch)/z以啟動模式下拷貝檔
                /B : Copy files in Backup mode.                             /b以備份模式copy
               /ZB : Use restartable mode; if access denied use Backup mode./zb表示優先使用啟動模式,否則使用備份模式
            /IPG:n : Inter-Packet Gap (ms), to free bandwidth on slow lines.
 
              /R:n : Number of Retries on failed copies - default is 1 million.
              /W:n : Wait time between retries - default is 30 seconds.
              /REG : Save /R:n and /W:n in the Registry as default settings.
              /TBD : Wait for sharenames To Be Defined (retry error 67).
 
   Destination options
 
    /A+:[RASHCNET] : Set file Attribute(s) on destination files + add.     /a+/a- 等參數表示對檔屬性進行操作,分別表示在檔被拷貝後為檔添加、去除某屬性
    /A-:[RASHCNET] : UnSet file Attribute(s) on destination files - remove.
              /FAT : Create destination files using 8.3 FAT file names only.
 
           /CREATE : CREATE directory tree structure + zero-length files only. /create表示只創建目錄結構並創建0長度的檔。目的是只要檔結構的情況下。
              /DST : Compensate for one-hour DST time differences ##
            /PURGE : Delete dest files/folders that no longer exist in source. /purge表示清理目標檔夾有而原始檔案夾裏沒有的檔()。通過這個命令,能保證原始檔案夾和目標檔夾結構與檔完全相同。這在創建鏡像備份時,非常有用
              /MIR : MIRror a directory tree - equivalent to /PURGE plus all subfolders (/E) /mir的作用等同於/purge /e 
 
   Logging options
                /L : List only - don't copy, timestamp or delete any files.
               /NP : No Progress - don't display % copied.
         /LOG:file : Output status to LOG file (overwrite existing log).
        /LOG+:file : Output status to LOG file (append to existing log).
                     UNILOG and UNILOG+ will output to a unicode logfile ##
               /TS : Include Source file Time Stamps in the output.
               /FP : Include Full Pathname of files in the output.
               /NS : No Size - don't log file sizes.
               /NC : No Class - don't log file classes.
              /NFL : No File List - don't log file names.
              /NDL : No Directory List - don't log directory names.
              /TEE : Output to console window, as well as the log file.
              /NJH : No Job Header.
              /NJS : No Job Summary.
 
 Repeated Copy Options
            /MON:n : MONitor source; run again when more than n changes seen.
            /MOT:m : MOnitor source; run again in m minutes Time, if changed. /mot後接的是時間(分鐘),是指Robocopy執行操作的最短時間;/mon後接的是最少檔修改個數。在監視過程中,會自動記錄時間和修改的次 數,只有同時符合以上兩個條件時,Robocopy才開始執行,執行完成後,這兩個資料會自動清零,並重新開始監視檔夾,除非用戶關閉命令提示符視窗或 按下Ctrl+Break.
 
     /RH:hhmm-hhmm : Run Hours - times when new copies may be started. /RH:hhmm-hhmm指定Robocopy開始的時間段和結束時間段,在這個時間段外,拷貝會被暫停。時間為24小時格式,4個數字長,從00002359,而且兩個數字不能相同
               /PF : Check run hours on a Per File (not per pass) basis.
 
 Job Options
      /JOB:jobname : Take parameters from the named JOB file.
     /SAVE:jobname : SAVE parameters to the named job file
             /QUIT : QUIT after processing command line (to view parameters). 
             /NOSD : NO Source Directory is specified.
             /NODD : NO Destination Directory is specified.
               /IF : Include the following Files.
 
Advanced options you'll probably never use
           /EFSRAW : Copy any encrypted files using EFS RAW mode.##
           /SECFIX : FIX file SECurity on all files, even skipped files.
           /TIMFIX : FIX file TIMes on all files, even skipped files.
 
               /XO : eXclude Older - if destination file exists and is the same date        /copy老文件
                     or newer than the source - don't bother to overwrite it.
         /XC | /XN : eXclude Changed | Newer files                   /xc不執行拷貝改變過得檔 /xncopy新增檔
         /XX | /XL : eXclude eXtra | Lonely files and dirs.  /保持現有檔現狀,只更新,不執行多餘的檔或目錄
                     An "extra" file is present in destination but not source, 
                     excluding extras will delete from destination. 
                     A "lonely" file is present in source but not destination
                     excluding lonely will prevent any new files being added to the destination.
 
/XF file [file]... : eXclude Files matching given names/paths/wildcards. /xf為指定不執行複製操作的檔類型,後面的檔案名支援通配符(/xf *.tmp *.bak)/xd表示排除後面指定的檔夾.
/XD dirs [dirs]... : eXclude Directories matching given names/paths.
                     XF and XD can be used in combination  e.g.
                     ROBOCOPY c:\source d:\dest /XF *.doc *.xls /XD c:\unwanted /S 
 
   /IA:[RASHCNETO] : Include files with any of the given Attributes
   /XA:[RASHCNETO] : eXclude files with any of the given Attributes/xa:[屬性]/xa:h表示將具有隱藏屬性的排除出複製範圍,與之相對應的是/ia,表示包括只對擁有指定屬性的執行操作。屬性有R:唯讀,A:存檔,S:系統,H:隱藏等幾種供選擇
               /IS : Include Same, overwrite files even if they are already the same. /is檔相同,不做copy,但是檔的屬性進行更新,經常和/copy一起結合使用比如:robocopy c:\windows\temp c:\windows\temp\downloads /is /copy:sou
               /IT : Include Tweaked files.
               /XJ : eXclude Junction points. (normally included by default).
 
            /MAX:n : MAXimum file size - exclude files bigger than n bytes. /max:n /max:6000000表示僅複製不大於6000000bytes的檔,數值單位為byte。如果是/min:6000000,則複製不小於6000000bytes的檔。兩個參數可以同時使用,界定複製檔大小的範圍
            /MIN:n : MINimum file size - exclude files smaller than n bytes.
         /MAXLAD:n : MAXimum Last Access Date - exclude files unused since n.
         /MINLAD:n : MINimum Last Access Date - exclude files used since n.
                     (If n < 1900 then n = n days, else n = YYYYMMDD date).
 
            /BYTES : Print sizes as bytes.
                /X : Report all eXtra files, not just those selected & copied.
                /V : Produce Verbose output log, showing skipped files.
              /ETA : Show Estimated Time of Arrival of copied files.

 

如何在.bat(批次檔)中使用日期變數

rem %date% 表示日期環境變數(2009/08/18 星期二)
rem %date:~0,4% 表示  日期環境變數中從第 0 個位置抓出 4 個字(2008)
rem %date:~5,2% 表示  日期環境變數中從第 5 個位置抓出 2 個字(08)
rem %date:~8,2% 表示  日期環境變數中從第 0 個位置抓出 4 個字(18)

echo %date:~0,4%%date:~5,2%%date:~8,2%
 
假設我們要進行檔案的複製而且要執行過程導入當天日期的log文件,建立backup.bat內容如下:
copy c:\*.* d:\backup > %date:~0,4%%date:~5,2%%date:~8,2%.log
type %date:~0,4%%date:~5,2%%date:~8,2%.log
pause

2009/08/10

ORACLE UPDATE 语句语法与性能分析的一点看法

轉載:網路

  为了方便起见,建立了以下简单模型,和构造了部分测试数据:
  在某个业务受理子系统BSS中,
  --客户资料
  create table customers
  (
   customer_id   number(8)    not null,  -- 客户标示
   city_name     varchar2(10) not null,  -- 所在城市
   customer_type char(2)      not null,  -- 客户类型

   ...
  )
  create unique index PK_customers on customers (customer_id)
  由于某些原因,客户所在城市这个信息并不什么准确,但是在
  客户服务部的CRM子系统中,通过主动服务获取了部分客户20%的所在
  城市等准确信息,于是你将该部分信息提取至一张临时表中:
  create table tmp_cust_city
  (
   customer_id    number(8) not null,
   citye_name     varchar2(10) not null,
   customer_type  char(2)   not null
  )
  

1) 最简单的形式
   --经确认customers表中所有customer_id小于1000均为'北京'
   --1000以内的均是公司走向全国之前的本城市的老客户:)
   update customers
   set    city_name='北京'
   where  customer_id<1000

2) 两表(多表)关联update -- 仅在where字句中的连接
   --这次提取的数据都是VIP,且包括新增的,所以顺便更新客户类别
   update customers  a       -- 使用别名
   set    customer_type='01' --01 为vip,00为普通
   where  exists (select 1
                  from   tmp_cust_city b
                  where  b.customer_id=a.customer_id
                 )

3) 两表(多表)关联update -- 被修改值由另一个表运算而来
   update customers a   -- 使用别名
   set    city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)
   where  exists (select 1
                  from   tmp_cust_city b
                  where  b.customer_id=a.customer_id
                 )
   -- update 超过2个值
   update customers a   -- 使用别名
   set    (city_name,customer_type)=(select b.city_name,b.customer_type
                                     from   tmp_cust_city b
                                     where  b.customer_id=a.customer_id)
   where  exists (select 1
                  from   tmp_cust_city b
                  where  b.customer_id=a.customer_id
                 )
   注意在这个语句中,
                                   =(select b.city_name,b.customer_type
                                     from   tmp_cust_city b
                                     where  b.customer_id=a.customer_id
                                    )
   与
                 (select 1
                  from   tmp_cust_city b
                  where  b.customer_id=a.customer_id
                 )
   是两个独立的子查询,查看执行计划可知,对b表/索引扫描了2篇;
   如果舍弃where条件,则默认对A表进行全表
   更新,但由于(select b.city_name from tmp_cust_city b where
where  b.customer_id=a.customer_id)
   有可能不能提供"足够多"值,因为tmp_cust_city只是一部分客户的信息,
   所以报错(如果指定的列--city_name可以为NULL则另当别论):
   
01407, 00000, "cannot update (%s) to NULL"
// *Cause:
// *Action:

   一个替代的方法可以采用:
   update customers a   -- 使用别名
   set    city_name=nvl((select b.city_name from tmp_cust_city b
where b.customer_id=a.customer_id),a.city_name)
   或者
   set    city_name=nvl((select b.city_name from tmp_cust_city b
where b.customer_id=a.customer_id),'未知')
   -- 当然这不符合业务逻辑了

4) 上述3)在一些情况下,因为B表的纪录只有A表的20-30%的纪录数,
   考虑A表使用INDEX的情况,使用cursor也许会比关联update带来更好的性能:
   
set serveroutput on

declare
    cursor city_cur is
    select customer_id,city_name
    from   tmp_cust_city
    order by customer_id;
begin
    for my_cur in city_cur loop

        update customers
        set    city_name=my_cur.city_name
        where  customer_id=my_cur.customer_id;
      
       /** 此处也可以单条/分批次提交,避免锁表情况 **/
--     if mod(city_cur%rowcount,10000)=0 then
--        dbms_output.put_line('----');
--        commit;
--     end if;
    end loop;
end;

5) 关联update的一个特例以及性能再探讨
   在oracle的update语句语法中,除了可以update表之外,也可以是视图,所以有以下1个特例:
    update (select a.city_name,b.city_name as new_name
            from   customers a,
                   tmp_cust_city b
            where  b.customer_id=a.customer_id
           )
    set    city_name=new_name
    这样能避免对B表或其索引的2次扫描,但前提是 A(customer_id) b(customer_id)必需是unique index
    或primary key。否则报错:
   
01779, 00000, "cannot modify a column which maps to a non key-preserved table"
// *Cause: An attempt was made to insert or update columns of a join view which
//         map to a non-key-preserved table.
// *Action: Modify the underlying base tables directly.

6)oracle另一个常见错误
   回到3)情况,由于某些原因,tmp_cust_city customer_id 不是唯一index/primary key
   update customers a   -- 使用别名
   set    city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)
   where  exists (select 1
                  from   tmp_cust_city b
                  where  b.customer_id=a.customer_id
                 )
   当对于一个给定的a.customer_id
   (select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)
   返回多余1条的情况,则会报如下错误:
   
01427, 00000, "single-row subquery returns more than one row"
// *Cause:
// *Action:

   一个比较简单近似于不负责任的做法是
   update customers a   -- 使用别名
   set    city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)

   如何理解 01427 错误,在一个很复杂的多表连接update的语句,经常因考虑不周,出现这个错误,
   仍已上述例子来描述,一个比较简便的方法就是将A表代入 值表达式 中,使用group by 和
   having 字句查看重复的纪录
   (select b.customer_id,b.city_name,count(*)
    from tmp_cust_city b,customers a
    where b.customer_id=a.customer_id
    group by b.customer_id,b.city_name
    having count(*)>=2
   )
 

如何取得各組織的線上人數

各組織的線上人數
SELECT   hou.organization_id,
         hou.NAME organization_name,
         COUNT(*) online_num
FROM     (SELECT DISTINCT responsibility_id,
                          user_id
          FROM            fnd_signon_audit_view) a, (SELECT *
                                                     FROM   org_access oa) oa,
         (SELECT *
          FROM   hr_all_organization_units_tl hou
          WHERE  LANGUAGE = 'US') hou
WHERE    a.responsibility_id = oa.responsibility_id(+)
AND      oa.organization_id = hou.organization_id(+)
GROUP BY hou.NAME, hou.organization_id;

2009/08/07

DELPHI控件安装与删除

控件安装

基本安装
1、对于单个控件,Componet-->install component..-->PAS或DCU文件-->install;
2、对于带*.dpk文件的控件包,File-->Open(下拉列表框中选*.dpk)-->install即可;
3、对于带*.bpl文件的控件包,Install Packages-->Add-->bpl文件名即可;
4、如果以上Install按钮为失效的话,试试Compile按钮;
5、是run time lib则在option下的packages下的runtimepackes加之。
如果编译时提示文件找不到的话,一般是控件的安装目录不在Delphi的Lib目录中,有两种方法可以解决:
1、反安装的源文件拷入到Delphi的Lib目录下;
2、或者Tools-->Environment Options中把控件源代码路径加入到Delphi的Lib目录中即可。
注意:所安装的控件是否与你所用的Delphi版本相适应。

RxLib的安装
首先在Delphi 5 的 IDE 中将以前版本的 Rxlib 反安装掉,删除 RXCTL5.BPL、RXDB5.BPL、 RXBDE5.BPL、DCLRX5.BPL、 DCLRXDB5.BPL 和DCLRXBD5.BPL。
打开 Rx 的运行包 RXCTL5.DPK,在 Package 窗口中按 Compile 按钮编译 RXCTL5.DPK ,然后用同样方法编译另两个运行包RXDB5.DPK 和 RXBDE5.DPK ,将编译后的三个 BPL 文件放到搜索路径中,如 WINDOWS\SYSTEM等。
在编译完运行包后你必须将 RX 的设计期包安装到 IDE 环境中。
打开 Rx 的设计期包 DCLRX5.DPK,在 Package 窗口中按 Compile 按钮编译,然后按 Install按钮将设计期包注册到组件面板中。用同样的方法安装 DCLRXDB5.DPK 和 DCLRXBD5.DPK。
注意:不要在 Delphi IDE 中保存包资源(package sources)!

帮助文件的安装
单击 Delphi 中的 Help 菜单下的 Customize 菜单项,这时会弹出 OpenHelp 对话框,选择在 Index 页下,打开 Edit 菜单下的 Add Files 菜单,添加你要加入的帮助菜单,这样你就可以在 Delphi 的 IDE 下使用该帮助文件了。

控件删除
在Component/Install Packages中删除。
选Component/configure Palette…
有pages和components两个区域
双击components区域,选中要删除得控件,下面有得Delete按钮
但系统提供的控件只能Hide,不能delete。
打开控件所在的包文件(*.dpk),从中删除控件那个文件,再重新编译该包即可
如果是整个控件包都要删除的话,project->Option->Packages,删掉那个packages,That would be ok~

2009/07/29

如何展開BOM表

如何使用Oracle 官方的 API 展開 BOM 表

Oracle Metalink Note:332133.1

The BOM exploder userexit is run (bompexpl.exploder_userexit) and seems to complete successfully.

The exploder is supposed to explode a bill into the BOM_EXPLOSION_TEMP table. However, the BOM_EXPLOSION_TEMP table is empty.


Code used to call the exploder:

--

-- BOM Exploder Userexit Example

-- Calls the bompexpl.exploder_userexit to explode a single item in a single org

-- Change v_item and v_org to suitable values

--



set serveroutput on



declare

v_item varchar2(240) := 'AS54888'; -- item to explode

v_org varchar2(3) := 'M1'; -- org in which item is exploded



v_cnt NUMBER := 0;



v_err_msg varchar2(240);

v_err_code NUMBER := 0;

v_verify_flag NUMBER := 0; -- DEFAULT 0

v_online_flag NUMBER := 2; -- DEFAULT 0

v_item_id NUMBER := 0; -- set to inventory_item_id of item to explode

v_org_id NUMBER := 0; -- set to organization_id of item to explode

v_alternate VARCHAR2(240) := NULL; -- DEFAULT null

v_list_id NUMBER := 0; -- for reports (default 0)

v_order_by NUMBER := 1; -- DEFAULT 1

v_grp_id NUMBER := 0; --

v_session_id NUMBER := 0; -- DEFAULT 0

v_req_id NUMBER := 0; -- DEFAULT 0

v_prgm_appl_id NUMBER := -1; -- DEFAULT -1

v_prgm_id NUMBER := -1; -- DEFAULT -1

v_levels_to_explode NUMBER := 1; -- DEFAULT 1

v_bom_or_eng NUMBER := 1; -- DEFAULT 1

v_impl_flag NUMBER := 1; -- DEFAULT 1

v_plan_factor_flag NUMBER := 2; -- DEFAULT 2

v_incl_lt_flag NUMBER := 2; -- DEFAULT 2

v_explode_option NUMBER := 2; -- DEFAULT 2

v_module NUMBER := 2; -- DEFAULT 2

v_cst_type_id NUMBER := 0; -- DEFAULT 0

v_std_comp_flag NUMBER := 0; -- DEFAULT 0

v_rev_date VARCHAR2(240); --

v_comp_code VARCHAR2(240) := NULL; --

v_expl_qty NUMBER := 1; -- DEFAULT 1



begin



-- item revision will be based on this explode date.

-- In this example, we use current date/time

v_rev_date := to_char(SYSDATE);



-- Find org_id

select mp.organization_id into v_org_id

from MTL_PARAMETERS mp

where mp.organization_code = v_org;



-- Find item_id

select inventory_item_id into v_item_id

from MTL_ITEM_FLEXFIELDS

where organization_id = v_org_id and item_number = v_item;



-- v_grp_id is a unique identifier for this run of the exploder

select bom_explosion_temp_s.nextval into v_grp_id from dual;



-- determine maximum levels to explode from bom_explosions

select maximum_bom_level into v_levels_to_explode

from bom_parameters where organization_id = v_org_id;



apps.bompexpl.exploder_userexit (

v_verify_flag,

v_org_id,

v_order_by,

v_grp_id,

v_session_id,

v_levels_to_explode,

v_bom_or_eng,

v_impl_flag,

v_plan_factor_flag,

v_explode_option,

v_module,

v_cst_type_id,

v_std_comp_flag,

v_expl_qty,

v_item_id,

v_alternate,

v_comp_code,

v_rev_date,

v_err_msg,

v_err_code);



if ( v_err_code <> 0 ) then

rollback;

dbms_output.put_line('ERROR: '

v_err_msg);

else

select count(*) into v_cnt from bom_explosion_temp where group_id=v_grp_id;

dbms_output.put_line('Count='

v_cnt);

commit;

dbms_output.put_line('.');

dbms_output.put_line('Group Id='

v_grp_id);

dbms_output.put_line('Org ='

v_org);

dbms_output.put_line('Item ='

v_item);

dbms_output.put_line('Ord Id ='

v_org_id);

dbms_output.put_line('Item Id='

v_item_id);

dbms_output.put_line('Levels ='

v_levels_to_explode);



end if;

end;

/



Cause

The BOM_EXPLOSION_TEMP table is a global temporary table. Data written to the table is automatically

removed after the SQL*PLUS session terminates. In addition, the data written in one SQL*PLUS session is

not available to any other SQL*PLUS session.





Solution

In the same SQL*PLUS session in which the exploder userexit is run, copy the data from the BOM_EXPLOSION_TEMP

table to another user created temporary table since the data in the BOM_EXPLOSION_TEMP table is only available to

the session in which you run the exploder and is deleted afterward. For example:



Start SQL*PLUS

Create a new table to hold the BOM_EXPLOSION_TEMP data



SQL> create table BOM_EXPLOSION_TEMP_SAVE as select * from BOM_EXPLOSION_TEMP;

Run the exploder in this same session



SQL> @<>

Copy the explosion data created by the exploder userexit into the new table you created



SQL> insert into BOM_EXPLOSION_TEMP_SAVE select * from BOM_EXPLOSION_TEMP;



SQL> commit;

Exit SQL*PLUS



When you exit, all data created for this session is automatically deleted from BOM_EXPLOSION_TEMP

because it is a global temporary table.

Your explosion data should now reside in the BOM_EXPLOSION_TEMP_SAVE table.