Forum Stats

  • 3,781,540 Users
  • 2,254,529 Discussions
  • 7,879,749 Comments

Discussions

creating package body sub programme present but it shows as its not present

pauljohny
pauljohny Member Posts: 42 Red Ribbon

This is the script Why am in unable to create a package body ??

CREATE or replace PACKAGE ko_mailing_pkg AS 

 PROCEDURE mail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar2) ;end ko_mailing_pkg;

/


CREATE OR REPLACE PACKAGE BODY ko_mailing_pkg AS

PROCEDURE mail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar) IS

BEGIN

 null;

END mail;

end ko_mailing_pkg;

but this throws error we can see the mail procedure clearly mentioned in package body

The output .. package created but not package body

SQL> start pb


Package created.


 11 /


Warning: Package Body created with compilation errors.


SQL> show error

Errors for PACKAGE BODY KO_MAILING_PKG:


LINE/COL ERROR

-------- -----------------------------------------------------------------

3/12   PLS-00323: subprogram or cursor 'MAIL' is declared in a package

     specification and must be defined in the package body

Best Answer

  • Billy Verreynne
    Billy Verreynne Software Engineer Member Posts: 28,648 Red Diamond
    Accepted Answer

    Parameter signature of the MAIL procedure.

    In your 1st posting the package header defines:

    PROCEDURE mail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar2)

    And the package body defines:

    PROCEDURE mail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar

    The MAIL procedure implemented by the body is not the MAIL procedure defined in the package specification.


    And please learn some basics about writing PL/SQL. PL/SQL is an Ada language implementation. Apply Ada programming standards as defined in https://en.wikibooks.org/wiki/Ada_Style_Guide/Introduction

    Reserve words in uppercase is beyond silly. So too are using Hungarian notations such as p_variable and name_pkg. It is NOT needed.

    pauljohny

Answers

  • pauljohny
    pauljohny Member Posts: 42 Red Ribbon

    When i tried this way it works What is the difference quite suprising ?

    SQL> CREATE or replace PACKAGE fmail AS

     2   PROCEDURE dmail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar);

     3 END fmail;

     4 /


    Package created.


    SQL> CREATE OR REPLACE PACKAGE BODY fmail AS

     2

     3   PROCEDURE dmail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar) IS

     4

     5   BEGIN

     6    null;

     7   END dmail;

     8 END fmail;

     9 /


    Package body created.

  • Billy Verreynne
    Billy Verreynne Software Engineer Member Posts: 28,648 Red Diamond
    Accepted Answer

    Parameter signature of the MAIL procedure.

    In your 1st posting the package header defines:

    PROCEDURE mail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar2)

    And the package body defines:

    PROCEDURE mail(p_from varchar2,p_to varchar2,p_sub varchar2,p_body varchar

    The MAIL procedure implemented by the body is not the MAIL procedure defined in the package specification.


    And please learn some basics about writing PL/SQL. PL/SQL is an Ada language implementation. Apply Ada programming standards as defined in https://en.wikibooks.org/wiki/Ada_Style_Guide/Introduction

    Reserve words in uppercase is beyond silly. So too are using Hungarian notations such as p_variable and name_pkg. It is NOT needed.

    pauljohny
  • pauljohny
    pauljohny Member Posts: 42 Red Ribbon

    Thank you ,Billy