查看PL/SQL编译时的错误信息

    编译无效对象是DBA与数据库开发人员常见的工作之一。对于编译过程中的错误该如何去捕获,下面给出两种捕获错误的方法。

一、当前数据库版本信息及无效对象

    1、查看当前数据库版本   

SQL> select * from v$version;                                      
                                                                   
BANNER                                                             
----------------------------------------------------------------   
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi   
PL/SQL Release 10.2.0.4.0 - Production                             
CORE    10.2.0.4.0      Production                                 
TNS for Solaris: Version 10.2.0.4.0 - Production                   
NLSRTL Version 10.2.0.4.0 - Production                             

    2、获得数据库中的无效对象

set linesize 180                                                                                        
col object_name format a45                                                                              
SELECT owner, object_name, object_type, status                                                          
FROM dba_objects                                                                                        
WHERE status = 'INVALID'                                                                                
     AND                                                                                                
     object_type IN ('PROCEDURE', 'FUNCTION', 'TRIGGER', 'VIEW', 'PACKAGE');                            
                                                                                                        
OWNER                          OBJECT_NAME                                   OBJECT_TYPE         STATUS 
------------------------------ --------------------------------------------- ------------------- -------
OTC_WRHS_POSITION              OTC_WRHS_POSITION_PCK_tmp                     PACKAGE             INVALID

    3、编译无效对象(编译方法很多,在此不一一列出)    

/**************************************************/                          
/* Author: Robinson Cheng                         */                          
/* Blog:   http://blog.csdn.net/robinson_0612     */                          
/* MSN:    robinson_0612@hotmail.com              */                          
/* QQ:     645746311                              */                          
/**************************************************/                          
	                                                                              
--注意该包对象中包体的名字含小写字符,因此编译时使用双引号括起来                
SQL> alter package "OTC_WRHS_POSITION"."OTC_WRHS_POSITION_PCK_tmp" compile body;

二、捕获编译错误
    1、使用show errors捕获错误   

SQL> show errors;                                                               
No errors.                                                                      
                                                                                
SQL> show errors package body "OTC_WRHS_POSITION"."OTC_WRHS_POSITION_PCK_tmp";  
No errors.                                                                      

    2、如果使用show errors无法查询到错误,直接查询视图dba_errors   

SQL> desc dba_errors;                                                                                                   
Name           Type           Nullable Default Comments                                                                 
-------------- -------------- -------- ------- ---------------------------------------------------------------          
OWNER          VARCHAR2(30)                                                                                             
NAME           VARCHAR2(30)                    Name of the object                                                       
TYPE           VARCHAR2(12)   Y                Type: "TYPE", "TYPE BODY", "VIEW", "PROCEDURE", "FUNCTION",              
"PACKAGE", "PACKAGE BODY", "TRIGGER",                                                                                   
"JAVA SOURCE" or "JAVA CLASS"                                                                                           
SEQUENCE       NUMBER                          Sequence number used for ordering purposes                               
LINE           NUMBER                          Line number at which this error occurs                                   
POSITION       NUMBER                          Position in the line at which this error occurs                          
TEXT           VARCHAR2(4000)                  Text of the error                                                        
ATTRIBUTE      VARCHAR2(9)    Y                                                                                         
MESSAGE_NUMBER NUMBER         Y                                                                                         
                                                                                                                        
SQL> select owner,name,TEXT from dba_errors where owner='OTC_WRHS_POSITION' and name='OTC_WRHS_POSITION_PCK_tmp' and    
  2  sequence=(select max(sequence) from dba_errors where owner='OTC_WRHS_POSITION');                                   
                                                                                                                        
OWNER                NAME                      TEXT                                                                     
-------------------- ------------------------- ------------------------------------------------------------             
OTC_WRHS_POSITION    OTC_WRHS_POSITION_PCK_tmp PLS-00103: Encountered the symbol "ULL" when expecting one o             
                                               f the following:                                                         
                                                                                                                        
                                                  . ( ) , * @ % & = - + < / > at in is mod remainder not re             
                                               m                                                                        
                                                  <an exponent (**)> <> or != or ~= >= <= <> and or like LI             
                                               KE2_                                                                     
                                                  LIKE4_ LIKEC_ between || multiset member SUBMULTISET_                 
                                               The symbol "." was substituted for "ULL" to continue.                    
                                                                                                                        


                                                   
                                              

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

清风智语

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值