日期:2014-05-17  浏览次数:20795 次

这个包体怎么编译都错!包头也贴出来!1
create   or   replace   package   body   Test_MD5   as
function   FN_GetMD5   (p_str   IN   VARCHAR2)RETURN   VARCHAR2   AS 
begin 
 RETURN   DBMS_OBFUSCATION_TOOLKIT.MD5( 
  input_string   =>   Upper(P_Str)); 
end; 
Function   FN_CheckUser 
    (P_UserName IN VARCHAR2 
     ,P_Password IN VARCHAR2) 
 Return   Number 
Is 
  L_Password   VarChar2(2000); 
begin 
 SELECT 
      Utl_Raw.Cast_To_Raw(Password) 
 INTO 
      L_Password 
 FROM  
      Test_User 
 WHERE  
      Upper(UserName)   =   UPPER(P_UserName); 
  If   Utl_Raw.Cast_To_Raw(FN_GetMD5(P_Password))=L_Password   Then 
     Return   1; 
  Else 
      Return   0; 
  End   If; 
exception 
 WHEN   NO_DATA_FOUND   THEN 
  Return   0; 
END; 
End; 


--------------------------包头


CREATE   OR   REPLACE   Package   Test_MD5   AS
Function   FN_GetMD5(P_Str   In   VarChar2)
Return   VarChar2;
Function   FN_CheckUser
(P_UserName   In   VarChar2
  ,P_Password   In   VarChar2)
Return   Number;
End;




------解决方案--------------------
用show errors;看看错误提示是什么?
再把错误提示帖出来!!方便找错误
------解决方案--------------------
字符错误!!楼主是直接从网上COPY 到sql*plus 上调试的吧?
你把有空格符的地方在SQL*PLUS 里全部重新用空格符代替就可以了!!!

记得还要建一个表:Test_User
CREATE TABLE Test_User (UserName VARCHAR2(30) NOT NULL
Password VARCHAR2(2000)NOT NUL)
-------------------------------------
1 CREATE OR REPLACE PACKAGE BODY Test_MD5 AS
2 function FN_GetMD5 (p_str IN VARCHAR2)
3 RETURN VARCHAR2 is
4 BEGIN
5 RETURN DBMS_OBFUSCATION_TOOLKIT.MD5(input_string => Upper(P_Str));
6 END FN_GetMD5;
7 Function FN_CheckUser
8 (P_UserName in VARCHAR2,
9 P_Password in VARCHAR2)
10 Return Number
11 Is
12 L_Password VarChar2(2000);
13 BEGIN
14 SELECT
15 Utl_Raw.Cast_To_Raw(Password)
16 INTO
17 L_Password
18 FROM
19 Test_User
20 WHERE
21 Upper(UserName) = UPPER(P_UserName);
22 If Utl_Raw.Cast_To_Raw(FN_GetMD5(P_Password))=L_Password Then
23 Return 1;
24 Else
25 Return 0;
26 End If;
27 EXCEPTION
28 WHEN NO_DATA_FOUND THEN
29 Return 0;
30 END;
31* End;
SQL> /

程序包主体已创建