Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8187297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:30:52+00:00 2026-06-07T02:30:52+00:00

I define a function outside a package, tried to call this function, failed. how

  • 0

I define a function outside a package, tried to call this function, failed.

how to fix it ? thanks

create or replace
package body test_erp AS    
    procedure init_data is
    begin             
        logMessage('procedure init_data');
    end init_data;        
end test_erp;
/

show error

error is

PLS-00221: 'LOGMESSAGE' is not a procedure or is undefined
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:30:54+00:00Added an answer on June 7, 2026 at 2:30 am

    As the error suggests logmessage is not a procedure. It’s a function. As functions return something you need to assign this to a variable. You know that logmessage returns a number so you need to declare a variable to put this return value into.

    create or replace package body test_erp AS    
        procedure init_data is
    
        l_success number;
    
        begin        
    
            l_message := logMessage('procedure init_data');
            dbms_output.put_line(to_char(l_success));
    
        end init_data;        
    
    end test_erp;
    /
    

    However, it looks like logmessage should in fact be a procedure. I assume you’re executing DML statements (update/insert) in this. A function call be used in a select statement unless this is the case, which means that there’s always the possibility of an error occurring. If logmessage were a procedure you can declare an out parameter to tell the calling procedure whether everything worked or not; something like the following:

    create or replace procedure logmessage( msg in varchar2, success out number) is
    
    begin
    
       insert into logs values(msg);
       success := 1;
    exception when others then
       success := 0;
    end logmessage;
    

    You can then call it as follows:

    create or replace package body test_erp AS    
       procedure init_data is
    
           l_success number;
    
       begin        
    
          logMessage('procedure init_data', l_success);
          dbms_output.put_line(to_char(l_success));
    
       end init_data;        
    end test_erp;
    /
    

    If logmessage isn’t going to be used outside the package test_erp I would put it inside the package; it keeps the namespace cleaner and avoids it getting used mistakenly be another package / call etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a user-define function for business hours calculation. This is my UDF. CREATE
Im trying to define a class friend function outside the namespace like this: namespace
Is it O.K. to define virtual function of class template outside its body? Virtual
When I define this function, template<class A> set<A> test(const set<A>& input) { return input;
Is this how you define a function in jQuery? $(document).ready( function () { var
So I have this function: (define (try try-block catch-block finally-block) ; Implements try/catch/finally like
In Python I can define a function as follows: def func(kw1=None,kw2=None,**kwargs): ... In this
Normally, I've seen prototype functions declared outside the class definition, like this: function Container(param)
I want to define an array outside main function so that it is shared
What I'm trying to do is the following: create or replace package MyPackage as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.