ORA-02019 錯誤處理

dawn009發表於2014-03-08

轉載於---&gt>http://blog.csdn.net/leshami/article/details/6688380
 ORA-02019 錯誤提示是未找到遠端資料庫的連線說明,通常發生在本地資料庫無法連線到遠端資料庫。引發該問題的原因很多,比如網路連線,連線方式(tnsnames),dblinkc的建立等等。而下面的描述的故障則比較奇特。                                                                                                  

一、錯誤現象    
  1. SQL> select * from scanfilename@dss.m85;   
  2.                                            
  3. select * from scanfilename@dss.m85         
  4.                                            
  5. ORA-02019: 未找到遠端資料庫的連線說明      
  6.                                            
  7. SQL> select * from xdoc_file@DSS.M85;      
  8.                                            
  9. select * from xdoc_file@DSS.M85            
  10.                                            
  11. ORA-02019: 未找到遠端資料庫的連線說明      
二、分析與解決                                                                                          
    1.當前資料庫版本                                                                                           
  1. SQL> select * from v$version;                                      
  2.                                                                    
  3. BANNER                                                             
  4. ----------------------------------------------------------------   
  5. Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production         
  6. PL/SQL Release 8.1.7.4.0 - Production                              
  7. CORE    8.1.7.2.1   Production                                         
  8. TNS for 32-bit Windows: Version 8.1.7.4.0 - Production             
  9. NLSRTL Version 3.4.1.0.0 - Production                              
  10.                                                                                                                          
    2.當前已建立的database link                                                                                
  1. SQL> select * from dba_db_links;                                                                                      
  2.                                                                                                                       
  3. OWNER                          DB_LINK    USERNAME   HOST            CREATED                                          
  4. ------------------------------ ---------- ---------- --------------- -----------                                      
  5. DIMS                           DSS.M85    VIEWPIC    PIC             2007-11-8 1                                      
  6.                                                                                                                       
  7. SQL> select * from v$dblink;   --&gt當前沒有正在使用的database link                                                     
  8.                                                                                                                       
  9. DB_LINK      OWNER_ID LOGGED_ON HETEROGENEOUS PROTOCOL OPEN_CURSORS IN_TRANSACTION UPDATE_SENT COMMIT_POINT_STRENGTH  
  10. ---------- ---------- --------- ------------- -------- ------------ -------------- ----------- ---------------------  
    3.下面的儲存過程使用了分散式資料庫                                                                        
  1. SQL> select text from dba_source where name='P_PROCESS_PIC_VALID';                                       
  2.                                                                                                          
  3. TEXT                                                                                                     
  4. --------------------------------------------------------------------------------                         
  5. PROCEDURE "P_PROCESS_PIC_VALID"                                                                          
  6.        (processDate IN DATE --處理日期,如果不傳入,就表示當天                                           
  7.        ) AS                                                                                              
  8.        recCount INT;                                                                                     
  9.        pictureName NVARCHAR2(50);                                                                        
  10.        mntnOperMask VARCHAR2(10);     --維護部操作人員賬號字首                                           
  11.        oper        NVARCHAR2(50);                                                                        
  12.        PicId  NVARCHAR2(50);                                                                             
  13.        FilmId NVARCHAR2(50);                                                                             
  14.        v_maxid      number;       --20100720                                                             
  15. BEGIN                                                                                                    
  16.     -------------------------------------------------20100720                                            
  17.     -- 已匯入的資料最大的ID                                                                              
  18.     select max(id) into v_maxid from T_scanfilename_m85;                                                 
  19.     -- 匯入新增的資料                                                                                    
  20.     execute immediate 'insert into T_scanfilename_m85                                                    
  21.                       select * from scanfilename@dss.m85                                                 
  22.                                                                                                          
  23. TEXT                                                                                                     
  24. --------------------------------------------------------------------------------                         
  25.                       where id>:COL_1'                                                                   
  26.     using v_maxid;                                                                                       
  27.     commit;                                                                                              
  28.     -------------------------------------------------20100720                                            
  29.     mntnOperMask := 'gl';                                                                                
  30.      --從圖系統匯入有效片資料                                                                            
  31.      INSERT INTO t_pic_xdoc_file(cph,cl,wldd,fx,wlrq,wlxm,lrsj,oper,picture_name                         
  32.        SELECT T1.cph,T1.cl,T1.wldd,T1.fx,T1.wlrq,T1.wlxm,T1.lrsj,T1.oper,T2.FILE                         
  33.          /*FROM xdoc_file@DSS.M85 T1,scanfilename@DSS.M85 T2*/ --20100720                                
  34.          FROM xdoc_file@DSS.M85 T1,T_scanfilename_m85 T2                                                 
  35.          WHERE T1.XH=T2.XH                                                                               
  36.              and t2.id>15717858                                                                          
  37.              and not exists (select picture_name from t_pic_xdoc_file where pict                         
  38.              AND substr(T1.oper,1,2)= mntnOperMask                                                       
  39.              and (t1.lrsj >=sysdate-3);                                                                  
  40.      -- 將圖文系統過來的有效片資料,分析處理後儲存到統計表中                                             
  41.      --處理有效片                                                                                        
  42.      FOR c IN(SELECT xf.*,ROWID FROM t_pic_xdoc_file xf WHERE status=1)                                  
  43.      LOOP                                                                                                
  44.                                                                                                          
  45. SQL> select table_name,owner from dba_tables where table_name in ('SCANFILENAME','XDOC_FILE');           
  46.                                                                                                          
  47. TABLE_NAME                     OWNER                                                                     
  48. ------------------------------ ------------------------------                                            
  49. SCANFILENAME                   DIMS                                                                      
  50.                                                                                                          
  51. SQL> select * from dims.scanfilename where rownum<5;                                                     
  52.                                                                                                          
  53.                                      ID FILENAME                                           XH            
  54. --------------------------------------- -------------------------------------------------- ------------  
  55.                                 8606178 V1_00000020361002320070614095523017900004.jpg                    
  56.                                 8605441 V1_00000002101002120070614095523011900023.jpg                    
  57.                                 8605445 V1_00000002101002120070614095523011900025.jpg                    
  58.                                 8605449 V1_00000002101002120070614095523011900027.jpg                    
    4.嘗試執行操作                                                                                            
  1. SQL> select * from scanfilename@dss.m85;                                                       
  2.                                                                                                
  3. select * from scanfilename@dss.m85                                                             
  4.                                                                                                
  5. ORA-02019: 未找到遠端資料庫的連線說明                                                          
  6.                                                                                                
  7. SQL> select * from xdoc_file@DSS.M85;                                                          
  8.                                                                                                
  9. select * from xdoc_file@DSS.M85                                                                
  10.                                                                                                
  11. ORA-02019: 未找到遠端資料庫的連線說明                                                          
  12.                                                                                                
  13. SQL> show user;                                                                                
  14. User is "SYS"                                                                                  
  15.                                                                                                
  16. SQL> conn dims/dims_12345@dmsdb                                                                
  17. Connected to Oracle8i Enterprise Edition Release 8.1.7.4.1                                     
  18. Connected as dims                                                                              
  19.                                                                                                
  20. SQL> select * from dba_db_links;                                                               
  21.                                                                                                
  22. OWNER           DB_LINK         USERNAME        HOST            CREATED                        
  23. --------------- --------------- --------------- --------------- -----------                    
  24. DIMS            DSS.M85         VIEWPIC         PIC             2007-11-8 1                    
  25.                                                                                                
  26. SQL> select * from user_db_links;                                                              
  27.                                                                                                
  28. DB_LINK         USERNAME        PASSWORD                       HOST            CREATED         
  29. --------------- --------------- ------------------------------ --------------- -----------     
  30. DSS.M85         VIEWPIC         VIEWPIC                        PIC             2007-11-8 1     
   5.切換帳戶後使用分散式資料庫,提示監聽不可用                                                           
  1. SQL> select * from xdoc_file@DSS.M85                                       
  2.                                                                            
  3. ORA-12514: TNS: 監聽程式不能解析在連線描述符中給出的 SERVICE_NAME          
  4.                                                                            
  5. SQL> select * from scanfilename@DSS.M85;                                   
  6.                                                                            
  7. select * from scanfilename@DSS.M85                                         
  8.                                                                            
  9. ORA-12514: TNS: 監聽程式不能解析在連線描述符中給出的 SERVICE_NAME          
  10.                                                                            
  11. pic =                                                                      
  12.   (DESCRIPTION =                                                           
  13.     (ADDRESS_LIST =                                                        
  14.       (ADDRESS = (PROTOCOL = TCP)(HOST = 100.100.1.31)(PORT = 1521))       
  15.     )                                                                      
  16.     (CONNECT_DATA =                                                        
  17.       (SERVER = DEDICATED)                                                 
  18.       (SERVICE_NAME = DSS)                                                 
  19.     )                                                                      
  20.   )                                                                        
    6.使用tnsping測試                                                                                       
  1. C:\>tnsping pic                                                                      
  2.                                                                                      
  3. TNS Ping Utility for 32-bit Windows: Version 8.1.7.4.0 - Production on 26-7月 -2     
  4. 011 15:32:35                                                                         
  5. (c) Copyright 1997 Oracle Corporation.  All rights reserved.                         
  6. Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=100.100.1.31)(PORT=1521))         
  7. OK(20毫秒)                                                                         
  8.                                                                                      
  9. C:\>sqlplus viewpic/viewpic@pic    --&gtsqlplus 不能登陸                               
  10.                                                                                      
  11. SQL*Plus: Release 8.1.7.0.0 - Production on 星期二 7月 26 15:33:15 2011              
  12.                                                                                      
  13. (c) Copyright 2000 Oracle Corporation.  All rights reserved.                         
  14.                                                                                      
  15. ERROR:                                                                              
  16. ORA-12514: TNS: 監聽程式不能解析在連線描述符中給出的 SERVICE_NAME                    
    7.檢視本地tnsnames.ora                                                                                    
  1. pic =                                                                                
  2.   (DESCRIPTION =                                                                     
  3.     (ADDRESS_LIST =                                                                  
  4.       (ADDRESS = (PROTOCOL = TCP)(HOST = 100.100.1.31)(PORT = 1521))                 
  5.     )                                                                                
  6.     (CONNECT_DATA =                                                                  
  7.       (SERVER = DEDICATED)                                                           
  8.       (SID = DSS)  --&gt(原來為service_name,將其改為SID)                               
  9.     )                                                                                
  10.   )                                                                                  
  11.                                                                                      
  12. C:\>sqlplus viewpic/viewpic@pic    --&gt再次使用sqlplus登陸正常                        
  13.                                                                                      
  14. SQL*Plus: Release 8.1.7.0.0 - Production on 星期三 7月 27 09:49:57 2011              
  15. (c) Copyright 2000 Oracle Corporation.  All rights reserved.                         
  16.                                                                                      
  17. 連線到:                                                                              
  18. Oracle8i Enterprise Edition Release 8.1.7.0.0 - 64bit Production                     
  19. With the Partitioning and Parallel Server options                                    
  20. JServer Release 8.1.7.0.0 - 64bit Production                                         
  21.                                                                                      
  22. SQL> select * from v$version;                                                        
  23.                                                                                      
  24. BANNER                                                                               
  25. ----------------------------------------------------------------                     
  26. Oracle8i Enterprise Edition Release 8.1.7.0.0 - 64bit Production                     
  27. PL/SQL Release 8.1.7.0.0 - Production                                                
  28. CORE    8.1.7.0.0       Production                                                   
  29. TNS for IBM/AIX RISC System/6000: Version 8.1.7.0.0 - Developmen                     
  30. NLSRTL Version 3.4.1.0.0 - Production                                                
  31.                                                                                      
  32. SQL> select * from scanfilename@DSS.M85 where rownum 
  33.                                                                                      
  34.         ID FILENAME                                           XH                     
  35. ---------- -------------------------------------------------- --------------------   
  36.    8606178 V1_00000020361002320070614095523017900004.jpg                             
  37.    8605441 V1_00000002101002120070614095523011900023.jpg                             
  38.    8605445 V1_00000002101002120070614095523011900025.jpg                             
  39.                                                  
    8.是什麼原因造成了需要將service_name改為SID,以前使用service_name一直正常。由於DSS.M85在故障前前曾重
        未做任何更改。Oracle 8之後推薦使用service_name,但實際上在Oracle 8使用service_name也可以正常使用。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29119536/viewspace-1103643/,如需轉載,請註明出處,否則將追究法律責任。

相關文章