Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL Stored Procedure Compilation Error (SQL Developer(2.1.1.64)/Oracle 10gR2/Windows XP-SP3)
PL/SQL Stored Procedure Compilation Error [message #484046] Fri, 26 November 2010 11:41 Go to next message
oruorainfo
Messages: 46
Registered: May 2010
Member
From the code below, i receive the following compile error:
Error(41,10): PLS-00323: subprogram or cursor 'GET_USERINFO' is declared in a package specification and must be defined in the package body. I am using SQL Developer(2.1.1.64) and
Oracle 10gR2. Would anyone know why please. Thank you.



--User Defined Object Specification

create or replace
TYPE USERS_TYPE_RS 

AS OBJECT (
  USERID          NUMBER,
  CODELOOKUPROLE  NUMBER,
  ORGID           NUMBER,
  FIRSTNAME       VARCHAR2(50)
          );


--Package Specification

create or replace
PACKAGE OTMP_TCIS_RS AS


PROCEDURE Get_UserInfo(
    o_OutCode OUT INT,
    i_language IN VARCHAR2);
    

FUNCTION Get_UserInfo(    
     i_language IN VARCHAR2)
      RETURN NUMBER;
    

PROCEDURE Apply_Users_Update(
	o_OutCode   OUT INT,
	i_users     IN USERS_TYPE_RS );
      

END OTMP_TCIS_RS;


--Package Body

create or replace
PACKAGE BODY OTMP_TCIS_RS
AS
	
  --1 PROCEDURE Get_UserInfo
PROCEDURE Get_UserInfo(
	o_OutCode OUT INT,
    	i_language IN VARCHAR2)
    AS
    
	v_ProcedureName     VARCHAR2(255) :='OTMP_TCIS_RS'||'.Get_UserInfo';
	v_ErrorCode         NUMBER;
	v_ErrorMessage      VARCHAR2(255);
	v_Parameters        VARCHAR2(4000) := SUBSTR('<parameters>' || 
                                             '</parameters>', 1, 4000);
	v_SQLStatement            VARCHAR(5000) ;
	exception_test            EXCEPTION     ;
	exception_test_msg        VARCHAR2(1000):= 'Exception test';
  	exception_validation      EXCEPTION;
  	exception_validation_msg  VARCHAR2(1000):= 'Validation failed';
	v_userid                  NUMBER;
  


BEGIN
    o_OutCode := 0;
    
    SELECT systemuser_seq.nextval
    INTO v_userid
    FROM dual;
    
    DECLARE 
        myusers USERS_TYPE_RS; 
    
    BEGIN
        myusers := USERS_TYPE_RS(v_userid,214,214,'TESTINGUSER');  
        
        OTMP_TCIS_RS.Apply_Users_Update(o_OutCode, myusers); 
        


        EXCEPTION
          WHEN exception_test THEN
            o_OutCode := -20099;
            OTMP_UTIL.InsertErrorMessage(v_ProcedureName, o_OutCode, 
			exception_test_msg,	v_SQLStatement);
           WHEN exception_validation THEN
            o_OutCode := -20100;
            OTMP_UTIL.InsertErrorMessage(v_ProcedureName, o_OutCode, 
			exception_validation_msg, v_Parameters);
          WHEN OTHERS THEN
            o_OutCode      := SQLCODE;
            v_ErrorCode    := SQLCODE;
            v_ErrorMessage := SUBSTR(SQLERRM, 1, 255);
            OTMP_UTIL.InsertErrorMessage(v_ProcedureName, v_ErrorCode, 
			v_ErrorMessage, v_Parameters);
    
    END;  

END Get_UserInfo;


FUNCTION Get_UserInfo(
         i_LanguageCode      VARCHAR2
    ) RETURN NUMBER IS
    
    v_result  NUMBER;
    v_OutCode NUMBER;
    
BEGIN
	
  OTMP_TCIS_RS.Get_UserInfo(v_OutCode, i_LanguageCode);
	
  IF (v_OutCode IS NULL OR v_OutCode != 0) THEN
    v_result := -100;
    DBMS_OUTPUT.PUT_LINE('Earth Station....we have a problem');
  END IF;
  
  RETURN v_result;

END Get_UserInfo;



PROCEDURE Apply_Users_Update(
		o_OutCode   OUT INT,
		i_users     IN USERS_TYPE_RS
                            )
    	IS
    
	v_ProcedureName VARCHAR2(255) :='OTMP_TCIS_RS'||'.Apply_Users_Update';
	v_ErrorCode     NUMBER;
	v_ErrorMessage  VARCHAR2(255);
  	v_Parameters        VARCHAR2(4000) := SUBSTR('<parameters>' || 
                                             '</parameters>', 1, 4000);
	
	v_SQLStatement            VARCHAR(5000) ;
	exception_test            EXCEPTION     ;
	exception_test_msg        VARCHAR2(1000):= 'Exception test';
  	exception_validation      EXCEPTION;
  	exception_validation_msg  VARCHAR2(1000):= 'Validation failed';
	v_LanguageID              NUMBER;
    

BEGIN
	o_OutCode := 0;
	
    
  BEGIN  
        DBMS_OUTPUT.PUT_LINE(i_users.userid||' '
	||i_users.CODELOOKUPROLE||' '
	||i_users.CODELOOKUPROLE||' '||i_users.ORGID||' '
	||i_users.FIRSTNAME);   



    EXCEPTION
      WHEN exception_test THEN
        o_OutCode := -20099;
        OTMP_UTIL.InsertErrorMessage(v_ProcedureName, o_OutCode, 
			exception_test_msg,	v_SQLStatement);
      WHEN exception_validation THEN
        o_OutCode := -20100;
        OTMP_UTIL.InsertErrorMessage(v_ProcedureName, o_OutCode, 
			exception_validation_msg, v_Parameters);
      WHEN OTHERS THEN
        o_OutCode      := SQLCODE;
        v_ErrorCode    := SQLCODE;
        v_ErrorMessage := SUBSTR(SQLERRM, 1, 255);
        OTMP_UTIL.InsertErrorMessage(v_ProcedureName, v_ErrorCode, 
				v_ErrorMessage, v_Parameters);
  
  END;    

END Apply_Users_Update;

END OTMP_TCIS_RS;


Re: PL/SQL Stored Procedure Compilation Error [message #484049 is a reply to message #484046] Fri, 26 November 2010 11:46 Go to previous messageGo to next message
Michel Cadot
Messages: 68763
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Use SQL*Plus and copy and paste your session, the WHOLE session. We can't know which line is line 41.

Quote:
PLS-00323: subprogram or cursor "string" is declared in a package specification and must be defined in the package body
Cause: A subprogram specification was placed in a package specification, but the corresponding subprogram body was not placed in the package body. The package body implements the package specification. So, the package body must contain the definition of every subprogram declared in the package specification.
Action: Check the spelling of the subprogram name. If necessary, add the missing subprogram body to the package body.


Regards
Michel


Re: PL/SQL Stored Procedure Compilation Error [message #484050 is a reply to message #484049] Fri, 26 November 2010 11:48 Go to previous messageGo to next message
Michel Cadot
Messages: 68763
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
By the way:

Quote:
         WHEN OTHERS THEN
            o_OutCode      := SQLCODE;
            v_ErrorCode    := SQLCODE;
            v_ErrorMessage := SUBSTR(SQLERRM, 1, 255);
            OTMP_UTIL.InsertErrorMessage(v_ProcedureName, v_ErrorCode, 
			v_ErrorMessage, v_Parameters);

"RAISE;" is missing to be a correct code.

Regards
Michel
Re: PL/SQL Stored Procedure Compilation Error [message #484051 is a reply to message #484050] Fri, 26 November 2010 11:57 Go to previous messageGo to next message
oruorainfo
Messages: 46
Registered: May 2010
Member
Thanks for the fast reply Mike, appreciate it. I do not have SQL Plus installed, but i can advise from the SQL Developer Window compile window that line 41 is:

OTMP_TCIS_RS.Apply_Users_Update(o_OutCode, myusers);

I am aware that Raise is missing, it was commented out, so i removed that statement. It looks like:--RAISE exception_test; It is only used to test exception handling.

Thanks.
Re: PL/SQL Stored Procedure Compilation Error [message #484054 is a reply to message #484051] Fri, 26 November 2010 12:53 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
You wrote: Quote:
It is only used to test exception handling.

WHEN OTHERS WHEN NOT FOLLOWED BY RAISE ITS ALWAYS ALMOST A BUG IN YOUR CODE AND IT HIDES ACTUAL ERROR.

Should not it be VARCHAR2 instead of VARCHAR?
v_SQLStatement            VARCHAR(5000) ;

and,
 DBMS_OUTPUT.PUT_LINE(i_users.userid||' '
	||i_users.CODELOOKUPROLE||' '
	||i_users.CODELOOKUPROLE||' '||i_users.ORGID||' '
	||i_users.FIRSTNAME);   


May be there are more...
Debug procedure OTMP_TCIS_RS.Apply_Users_Update.

It would always be better to /add one module at a time in your package then compile and verify.It should make things easier for you.


Regards
Ved

[Updated on: Fri, 26 November 2010 13:11]

Report message to a moderator

Re: PL/SQL Stored Procedure Compilation Error [message #484055 is a reply to message #484054] Fri, 26 November 2010 13:22 Go to previous messageGo to next message
oruorainfo
Messages: 46
Registered: May 2010
Member
Thanks Ved! The code compiles and works with out the Function in the Body and Specification.

I added the wrapper function to allow the Stored Procedure to be call by a Java App (using Beehive).

It is only when i add the Function to the Specification section that i get the compile error!


The Raise does not hide any errors. When RAISE is un-commented, the "WHEN exception_test THEN" section is executed.

Have modified the Varchar to Varchar2..Thanks Ved for your response.
Re: PL/SQL Stored Procedure Compilation Error [message #484058 is a reply to message #484055] Fri, 26 November 2010 14:25 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9106
Registered: November 2002
Location: California, USA
Senior Member
The declarations in the package and package body must match. In your package you have:

FUNCTION Get_UserInfo(
i_language IN VARCHAR2)
RETURN NUMBER;

but in your package body you have:

FUNCTION Get_UserInfo(
i_LanguageCode VARCHAR2
) RETURN NUMBER
Re: PL/SQL Stored Procedure Compilation Error [message #484062 is a reply to message #484058] Fri, 26 November 2010 16:48 Go to previous messageGo to next message
oruorainfo
Messages: 46
Registered: May 2010
Member
Thanks Barbara for your response, i have tried that, but still the same compilation error...Thanks for looking at it though.
Re: PL/SQL Stored Procedure Compilation Error [message #484063 is a reply to message #484062] Fri, 26 November 2010 17:21 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9106
Registered: November 2002
Location: California, USA
Senior Member
oruorainfo wrote on Fri, 26 November 2010 14:48

...i have tried that, but still the same compilation error...


You tried what? According to what you posted, you have two different parameter names for the Get_UserInfo function in your package and your package body. You need to either make them both i_Lanauge or both i_LanguageCode. You cannot have one in the package and the other in the package body. That is what is causing the error in the code that you posted and fixing it resolves that error. If not, then you are not running what you have posted. As Michel previously stated, you need to post a copy and paste of a run of the compilation of the code and resulting error messages, complete with line numbers, run from SQL*Plus. You should also provide any related items, such as create statements for objects referenced in the code.

Re: PL/SQL Stored Procedure Compilation Error [message #484064 is a reply to message #484063] Fri, 26 November 2010 17:38 Go to previous message
oruorainfo
Messages: 46
Registered: May 2010
Member
Barbara, you are absolutely correct! In my anxiousness to make the change i made a typo and that fooled me. As soon as i read your second post here i went back to checked again and yes indeed your suggestion has solved my problem. My apologies, and I thank you very much for your patience and kindness and wish you a wonderful weekend! Thanks again Barbara! Smile
Previous Topic: Split single row into multiple rows containing time periods per Year
Next Topic: tricky concatenation of data in one column
Goto Forum:
  


Current Time: Thu Jul 24 20:14:40 CDT 2025