creating a package body

Hello world
I am trying to create a package body, but I get an error message saying package created with complication. What am I missing? Thanks in advance.
CREATE OR REPLACE PACKAGE BODY MY_PACK
IS
PROCEDURE MY_PROC (NUMBER, NUMBER OF B)
IS
C NUMBER 4;
BEGIN
C: = A + B;
DBMS_OUTPUT. PUT_LINE ("RESULT =" |) (C);
END;
FUNCTION NETSAL (TEMPNO EMP. EMPNO % TYPE RETURN NUMBER)
IS
RAHAL EMP. SAL % TYPE;
TCOMM EMP.COMM%TYPE;
NETSAL NUMBER (10.2);
BEGIN
SELECT SAL, NVL (COMM, 0) IN RAHAL, TCOMM FROM EMP WHERE EMPNO = TEMPNO;
NETSAL: = RAHAL + TCOMM;
RETURN (NETSAL);
END;
END;
/

A package is in two parts

(1) specification
2 body)

What you are creating is the body are you created the specification using the code below:

/ * Formatted on 2013/01/06 22:50 (trainer more v4.8.8) * /.
CREATE or REPLACE PACKAGE my_pack
IS
PROCEDURE my_proc (a NUMBER, b NUMBER);

FUNCTION netsal (tempno emp.empno%TYPE)
RETURN NUMBER;
END;

Tags: Database

Similar Questions

  • Can I create a package without specifying body?

    Can I create a package without specifying body?

    SQL > create the package body no_specification as start null; end no_specification;

    2.

    WARNING: The body of a Package created with compilation errors.

    SQL > show errors

    PACKAGE BODY NO_SPECIFICATION errors:

    LINE/COL ERROR

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

    0/0 PL/SQL: analysis of completed Compilation unit

    1/14 PLS-00201: identifier 'NO_SPECIFICATION' must be declared

    1/14 PLS-00304: impossible to compile a body of 'NO_SPECIFICATION' without sound

    specification of the

  • Package body is not VALID

    Hi friends,

    Could you help me understand this behavior in oracle.

    SQL > create or replace package mypkg is

    2 number of v_statevar: = 40;

    3 procedure MyProc;

    4 end mypkg;

    5.

    Package created.

    SQL > create or replace package body is mypkg

    2 procedure MyProc is

    3 myval number;

    4 start

    5. Select x

    6 in myval

    7 of dependonme;

    8

    9 - myval: = myval * mypkg.v_statevar;

    10 DBMS_OUTPUT. Put_line (' my result is: ' | myVal);

    11 end;

    12 end mypkg;

    13.

    Package body created.

    SQL > select object_name, object_type, status from user_objects where object_name = 'MYPKG ';

    OBJECT_NAME OBJECT_TYPE STATUS

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

    PACKAGE VALID MYPKG

    VALID PACKAGE BODY MYPKG

    SQL > set serveroutput on

    SQL > exec mypkg.myproc;

    My result is: 5

    PL/SQL procedure successfully completed.

    SQL > create or replace package mypkg is

    2 number of v_statevar: = 150;

    3 procedure MyProc;

    4 end mypkg;

    5.

    Package created.

    SQL > select object_name, object_type, status from user_objects where object_name = 'MYPKG ';

    OBJECT_NAME OBJECT_TYPE STATUS

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

    PACKAGE VALID MYPKG

    INVALID BODY PACKAGE MYPKG

    SQL > set serveroutput on

    SQL > exec mypkg.myproc;

    My result is: 5

    PL/SQL procedure successfully completed.

    SQL > select object_name, object_type, status from user_objects where object_name = 'MYPKG ';

    OBJECT_NAME OBJECT_TYPE STATUS

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

    PACKAGE VALID MYPKG

    VALID PACKAGE BODY MYPKG

    SQL >

    How did change the value of the variable in the package specification makes the invalid package body.

    How execution of the procedure of the package is once again the VALID State.

    Kimmy says:

    Hello carine,.

    I'm just setting the variable in the notebook, that variable was not referred to the procedure in the package body, also I'm not change any signature/details of the procedure described in the package specification, then what do the package body are invalid.

    There are two parts to this.

    (a) by recompiling package specifications, you then automatically invalidates all objects in the database that dependent on it.  In this case, the package body is dependent on, so get marked as invalid.  When you try and run something in the package Oracle try to compile the package, if it succeeds, it will mark it as valid again (as in your case).

    (b) the variables and declarations of a package (public and private) are what constitutes the 'State '.  By calling the package, you instantiate a copy in memory to create this state of package for this instantiation of the entire session.  By recompiling package specifications (it's not fair that you change the value of the variable, you recompile the spec), you can invalidate the State in memory and therefore potentially invalidate the package body.  It depends on your version of the database.  In 10g, by invalidating state you will get an exception "State package rejected" when you try to run the package after the change, and then it will automatically compile and validate the package, so that it eventually works ok.  From 11 g, there is more fine grain dependencies on the State, so if the change you have made has no effect on what you run, it can validate and run without causing the exception 'package State scrapped ';. He would only do that if it's something that you used.

  • Package body dropped, but showing invalid

    Nice day:

    Oracle 11 g 2

    I created a Package with Package bodies, procedures 3, which works very well.  I can call it without error.  However, if I run this query:

    SELECT *.

    From user_objects

    Situation WHERE = "INVALID."

    I get the following result:

    OBJECT_NAMESUBOBJECT_NAMEOBJECT_IDDATA_OBJECT_IDOBJECT_TYPECREATEDLAST_DDL_TIMETIMESTAMPSTATUSTEMPORARYGENERATEDSECONDARYNAMESPACEEDITION_NAME
    TASK_PROCEDURES28700PACKAGE BODY5 July 14July 11, 142014-07 - 11:18:42:39Not validNNN2

    It is an old package body, that I dropped it about 4 days ago.  That is always supposed to show if I run this query?

    I work with Oracle SQL Developer, using almost the same version too. I don't think that it has nothing to do with the tool as the data dictionary shows this info too.

    Could you post the exact commands that you run from a sql more session? And the sql like too much output.

    Example (demo of pseudo code)

    SQL > alter the package xxx body compilation;

    SQL > compiled package.

    SQL > show errors

    SQL > no error

    SQL > drop package xxx;

    SQL > package abandoned;

    SQL > drop package body xxx.

    ???

    SQL > select xxx.someFunction from double;

    I could explain the behavior if you have enabled the editions (CDE). But there is no air if in your case.

    Just to be absolutely sure of it. Make the select statement and after the release:

    select object_name, object_type, namespace, edition_name
    from user_objects_ae
    where object_name = 'YOURPACKAGENAME';
    
  • Package body error

    Hello people.

    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product

    PL/SQL Release 10.2.0.1.0 - Production

    Hope you are all well.  I am creating a package as a procedure body, but I get the following error:

    • Error (37.7): PL/SQL: statement ignored
    • Error (38,15): PLS-00201: identifier ' C1. Email_address' must be declared

    I'm fairly inexperienced, so the resolution may be simple, but I'm still confused as to what to do.  Here is my code:

    create or replace 
    PACKAGE BODY            "CHECK_VISA_DATE" 
    AS
    PROCEDURE "VISA_EXPIRY"
    IS
        l_msg_body varchar2(32000) := null;
        l_count number := 0;
    BEGIN
    FOR c1 IN
        (SELECT E.EMPLOYEE_ID,
        E.CLOCK_NUMBER,
        E.LAST_NAME,
        E.FIRST_NAME,
        E.EMAIL_ADDRESS,
        E.VISA_EXPIRY
        FROM EMPLOYEE E,
        EMPLOYEE_CONTRACT EC
        WHERE E.EMPLOYEE_ID = EC.EMPLOYEE_ID
        AND EC.ACTUAL_END IS NULL
        AND EC.FUTURE_CONTRACT = 1
        AND EC.SUB_TASK = 1
        AND E.VISA_EXPIRY < SYSDATE + 60)
    LOOP
      IF l_count = 0
        THEN
            L_MSG_BODY :=
            'As of today, your visa is due to 
            expire in 60 days '||chr(10)||
            CHR(10)||
            ' Visa Expiration: '|| c1.VISA_EXPIRY;
      END IF;
        l_count := l_count + 1;
    END LOOP;
    
    
    IF L_MSG_BODY IS NOT NULL
      THEN
          HTMLDB_MAIL.SEND(
          P_TO => c1.EMAIL_ADDRESS,
          P_BODY => L_MSG_BODY,
          P_SUBJ => 'Visa Expiration '||
          c1.VISA_EXPIRY);
    END IF;
    END "VISA_EXPIRY";
    END "CHECK_VISA_DATE";
    

    Hello

    AquaNX4 wrote:

    ...

    Output is an email, so there really isn't any type of insert statements, or additional information to give...

    If there is no relevant information in AMPEMP or EMP_CONTRACT tables, then you don't need to question the in your procedure.

    • Error (24,112): PLS-00302: component 'VISA_EXPIRY' must be declared

    There is no column called

    VISA_EXPIRis the cursor.  Did you mean to say

    E VISA_EXPIR?

  • Can only establish us a specific procedure in the package body?

    Hi experts

    Say we have a package as follows:

    package my_package

    a procedure;

    procedure b;

    procedure c;

    end packege my_package;

    my_package package body

    procedure a

    is

    ....

    end;

    procedure b

    is

    ....

    end b;

    procedure c

    is

    ....

    c end;

    end of packet my_package;

    I want to only change the procedure has, should I compile the body together for this? Can I do to compile the procedure like the following?

    create or replace the my_package.procedure one

    is

    ....

    end my_package.a;

    Thank you

    Hello

    No, you must recompile the entire body.  There is no way to compile a procedure in the package.

  • PLS-00323: subprogram or cursor is declared in a package specification and must be defined in the package body

    Hi all

    Please help me understand why I receive PLS-00323 error when my function exists in the header and body of the package.

    Please find below the source code.

    Maybe I should post more details here, please tell me what else should I show to get help.

    I tried to compile my drawing

    EXEC DBMS_UTILITY.compile_schema (pattern = > 'ZVIT');

    but still

    Select * from user_errors

    Returns

    NAME TYPE SEQUENCE LINE (LINE)

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

    TEXT

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

    ATTRIBUTE MESSAGE_NUMBER

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

    PACKAGE 2 8 12 PKG_PK8842_ACCNOTMOVE BODY

    PLS-00323: subprogram or cursor "ACCNOTMOVEFIZ" is declared in a specific package

    cation and must be defined in the package body

    ERROR 323

    PACKAGE 1 3 12 PKG_PK8842_ACCNOTMOVE BODY

    PLS-00323: subprogram or cursor "ACCNOTMOVEJUR" is declared in a specific package

    cation and must be defined in the package body

    ERROR 323

    2 selected lines.

    source code:

    CREATE OR REPLACE PACKAGE ZVIT. PKG_PK8842_AccNotMove

    AS

    FUNCTION AccNotMoveJUR)

    p_contragentId dwh_CR_contragent.ID%TYPE,

    p_date Date)

    RETURN number;

    FUNCTION AccNotMoveFIZ)

    p_contragentId dwh_CR_contragent.ID%TYPE,

    p_date Date)

    RETURN number;

    FUNCTION DtLastMove)

    p_Id B2_OLAP. DIMAACCOUNT_ALL.ID%TYPE)

    Date of RETURN;

    END;

    /

    CREATE OR REPLACE PACKAGE BODY ZVIT. PKG_PK8842_AccNotMove

    AS

    FUNCTION AccNotMoveJUR)

    p_contragentId zvit.dwh_CR_contragent.ID%TYPE,

    p_date Date)

    RETURN number

    IS

    l_Result Number (1);

    l_contragentId zvit.dwh_CR_contragent.ID%TYPE;

    l_dateopen Date;

    Date of l_dtMove1;

    Date of l_dtMove2;

    BEGIN

    l_Result: = 0;

    BEGIN

    Select Distinct a.contragentid

    In l_contragentId

    OF B2_OLAP. DIMAACCOUNT_ALL one

    where a.contragentid = p_contragentId

    and a.BACCOUNTID in (2600,2650)

    and a.ACCOUNTSTATEID not in (1,2);

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_contragentId: = NULL;

    END;

    IF l_contragentId IS NOT NULL THEN

    l_Result: = 0;

    ON THE OTHER

    BEGIN

    Select MAX (a.dateopen)

    In l_DateOpen

    OF B2_OLAP. DIMAACCOUNT_ALL one

    where a.contragentid = p_contragentId

    and a.BACCOUNTID in (2600,2650)

    and a.ACCOUNTSTATEID <>2

    and a.DateOpen > p_date;

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_DateOpen: = NULL;

    END;

    IF l_DateOpen IS NOT NULL THEN

    l_Result: = 0;

    ON THE OTHER

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2600,2650)

    and d.ACCOUNTBID = a.Id

    and d.arcdate > = p_date

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3)

    and not in Substr (d.accountano, 1, 4) ('2608 ', ' 2658');

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    IF l_dtMove1 IS NULL THEN

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2600,2650)

    and d.ACCOUNTBID = a.Id

    and d.arcdate > = p_date

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3)

    and not in Substr (d.accountano, 1, 4) ('2608 ', ' 2658');

    - and d.DOCUMENTSTATEID = 2

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    END IF;

    IF l_dtMove1 IS NULL THEN

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2600,2650)

    and d.ACCOUNTAID = a.Id

    and d.arcdate > = p_date

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3);

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    END IF;

    IF l_dtMove1 IS NULL THEN

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2600,2650)

    and d.arcdate > = p_date

    and d.ACCOUNTAID = a.Id

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3);

    - and d.DOCUMENTSTATEID = 2

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    END IF;

    IF l_dtMove1 IS NULL THEN

    l_Result: = 1;

    On the other

    l_Result: = 0;

    End If;

    END IF;

    END IF;

    RETURN l_Result;

    END AccNotMoveJUR;

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

    FUNCTION AccNotMoveFIZ)

    p_contragentId zvit.dwh_CR_contragent.ID%TYPE,

    p_date Date)

    RETURN number

    IS

    l_Result Number (1);

    l_contragentId zvit.dwh_CR_contragent.ID%TYPE;

    l_dateopen Date;

    Date of l_dtMove1;

    BEGIN

    l_Result: = 0;

    BEGIN

    Select Distinct a.contragentid

    In l_contragentId

    OF B2_OLAP. DIMAACCOUNT_ALL one

    where a.contragentid = p_contragentId

    and a.BACCOUNTID in (2620,2625)

    and a.ACCOUNTSTATEID not in (1,2);

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_contragentId: = NULL;

    END;

    IF l_contragentId IS NOT NULL THEN

    l_Result: = 0;

    ON THE OTHER

    BEGIN

    Select MAX (a.dateopen)

    In l_DateOpen

    OF B2_OLAP. DIMAACCOUNT_ALL one

    where a.contragentid = p_contragentId

    and a.BACCOUNTID in (2620,2625)

    and a.ACCOUNTSTATEID <>2

    and a.DateOpen > p_date;

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_DateOpen: = NULL;

    END;

    IF l_DateOpen IS NOT NULL THEN

    l_Result: = 0;

    ON THE OTHER

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2620,2625)

    and d.ACCOUNTBID = a.Id

    and d.arcdate > = p_date

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3)

    and Substr(d.accountano,1,4) <>'2628';

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    IF l_dtMove1 IS NULL THEN

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2620,2625)

    and d.arcdate > = p_date

    and d.ACCOUNTBID = a.Id

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3)

    and Substr(d.accountano,1,4) <>'2628';

    - and d.DOCUMENTSTATEID = 2

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    END IF;

    IF l_dtMove1 IS NULL THEN

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2620,2625)

    and d.ACCOUNTAID = a.Id

    and d.arcdate > = p_date

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3);

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    END IF;

    IF l_dtMove1 IS NULL THEN

    BEGIN

    SELECT MAX (d.arcdate)

    In l_dtMove1

    OF B2_OLAP. DIMAACCOUNT_ALL has,

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE a.contragentid = p_contragentId

    and a.BACCOUNTID in (2620,2625)

    and d.arcdate > = p_date

    and d.ACCOUNTAID = a.Id

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3);

    - and d.DOCUMENTSTATEID = 2

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_dtMove1: = NULL;

    END;

    END IF;

    IF l_dtMove1 IS NULL THEN

    l_Result: = 1;

    On the other

    l_Result: = 0;

    End If;

    END IF;

    END IF;

    RETURN l_Result;

    END AccNotMoveFIZ;

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

    FUNCTION DtLastMove)

    p_Id B2_OLAP. DIMAACCOUNT_ALL.ID%TYPE)

    Date of RETURN

    IS

    l_Result Date;

    Date of l_DtLast1;

    Date of l_DtLast2;

    Date of l_DtLast3;

    Date of l_DtLast4;

    BEGIN

    l_Result: = NULL;

    BEGIN

    SELECT MAX (d.arcdate)

    In l_DtLast1

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE d.ACCOUNTBID = p_Id

    - and d.arcdate > = p_date

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3)

    and Substr (d.accountano, 1, 4) not in ('2608', ' 2658 ', ' 2628');

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_DtLast1: = NULL;

    END;

    BEGIN

    SELECT MAX (d.arcdate)

    In l_DtLast2

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE d.ACCOUNTBID = p_Id

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3)

    and Substr (d.accountano, 1, 4) not in ('2608', ' 2658 ', ' 2628');

    - and d.DOCUMENTSTATEID = 2

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_DtLast2: = NULL;

    END;

    BEGIN

    SELECT MAX (d.arcdate)

    In l_DtLast3

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE d.ACCOUNTAID = p_Id

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3);

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_DtLast3: = NULL;

    END;

    BEGIN

    SELECT MAX (d.arcdate)

    In l_DtLast4

    B2_OLAP.AR_DOCUMENT d,

    B2_OLAP. DIMDOCUMENTTYPE dt

    WHERE d.ACCOUNTAID = p_Id

    and d.DOCUMENTTYPEID = dt.id

    and dt. OPERATIONTYPEBYSUMMAID not to (2,3);

    - and d.DOCUMENTSTATEID = 2

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_DtLast4: = NULL;

    END;

    l_DtLast1:=NVL(l_DtLast1,to_date('01.01.1900','dd.mm.yyyy'));

    l_DtLast2:=NVL(l_DtLast2,to_date('01.01.1900','dd.mm.yyyy'));

    l_DtLast3:=NVL(l_DtLast3,to_date('01.01.1900','dd.mm.yyyy'));

    l_DtLast4:=NVL(l_DtLast4,to_date('01.01.1900','dd.mm.yyyy'));

    l_Result: = Greatest (l_DtLast1, l_DtLast2, l_DtLast3, l_DtLast4);

    IF l_Result = TO_DATE('01.01.1900','dd.mm.yyyy') THEN

    l_Result: = NULL;

    END IF;

    RETURN l_Result;

    END DtLastMove;

    ---////////////////////////////////////////////////////

    END;

    /

    You declare your parameter with a different type between the specification and body, your statements must match.

  • How to create a package with the procedures?

    Referring by the net, I've written the following PCK file. I installed my Oracle database 11g in VirtualBox (Win XP). I can able to select tables using the query from the host (Windows 7)

    CREATE OR REPLACE PACKAGE APEX_SYS_PCK

    AS

    TYPE refcursortype IS REF cursor

    PROCEDURE GET_USER_DETAILS)

    D1 ON refcursortype,

    P_USER IN VARCHAR2,

    P_PASS IN VARCHAR2);

    END APEX_SYS_PCK;

    /

    CREATE OR REPLACE PACKAGE BODY APEX_SYS_PCK

    AS

    PROCEDURE GET_USER_DETAILS)

    D1 ON refcursortype,

    P_USER IN VARCHAR2,

    P_PASS IN VARCHAR2)

    IS BEGIN

    OPEN D1 FOR SELECT * FROM APEX. PEOPLE;

    END GET_USER_DETAILS;

    END APEX_SYS_PCK;

    /

    When I try to run the script, I get the following error. How to solve this problem? If there is an error in this package please correct!

    • Project: sqldev.temp:/IdeConnections%23vAPEX.jpr
    • F:\PACKAGES\APEX_SYS_PCK. SQL
    • Error: PL/SQL: analysis of completed Compilation unit
    • Error (1.14): PLS-00905: APEX oppose. APEX_SYS_PCK is not valid
    • Error (1.14): PLS-00304: impossible to compile 'APEX_SYS_PCK' body without its specification

    You are missing a semicolon after

    TYPE refcursortype IS REF cursor

    in the specifications of your package.

  • table/view not found when creating a package, but can execute sql...

    I'm trying to create a package I'm ora-00942 table or view does not exsit, but when I run with the same user tries to create the package in the sql statement that gives NO error through fine.

    Any idea what can cause that?

    -drop table demo_hdr_trgt

    -drop table demo_hdr_stg

    -It's the tabe belong to the other user not my own schema

    connect tstdata/tstdata

    create the table demo_hdr_stg as floor (dbms_random.value (1,101)) select id, floor (dbms_random.value (1001,100001)) double amt connect by level < = 100

    /

    -It's my diagram

    connect me3/me3

    create the table demo_hdr_trgt in select * from hdr_stg where 1 = 0

    /

    Select * from tstdata.demo_hdr_stg by id

    /

    Select * from demo_hdr_trgt by id

    /

    -business for this temporary table to demo rule

    ALTER TABLE demo_hdr_trgt add PRIMARY KEY (id)

    /

    -table to the control of the error for the DML

    Start

    DBMS_ERRLOG. CREATE_ERROR_LOG('tstdata.) DEMO_HDR_STG');

    end

    /

    -Follow-up of the load table if he succeeds

    CREATE TABLE demo_RESULT_TAB

    (VARCHAR2 (100) 'RUN_NAME',)

    VARCHAR2 (100) "V_MODULE."

    VARCHAR2 (100) "V_ACTION."

    NUMBER OF "ROWCOUNT".

    )

    /

    -Follow-up of the other error table

    CREATE TABLE demo_ERROR_TAB

    (VARCHAR2 (100) 'RUN_NAME',)

    VARCHAR2 (100) "V_MODULE."

    VARCHAR2 (100) "V_ACTION."

    NUMBER OF "SQLCODE"

    "SQLERRM' VARCHAR2 (4000).

    "CALL_STACK' CLOB

    )

    /

    -package charge demo

    create or replace package demo_hdr_pkg as

    procedure hdr_ldr (run_name varchar2);

    end demo_hdr_pkg

    /

    create or replace package body demo_hdr_pkg as

    procedure hdr_ldr (run_name varchar2) is

    number of v_sqlcode;

    v_sqlerrm varchar2 (1000);

    v_module varchar2 (100): = "demo_hdr_pkg.hdr_ldr";

    v_action varchar2 (100): = "insert into hdr_trgt";

    number of v_rowcount;

    Start

    DBMS_APPLICATION_INFO.set_module (module_name = > v_module,)

    action_name = > v_action);

    -the sql code that gives ora-00942 errors that I can review independent

    -INSERT / * + append PARALLEL * /.

    INSERT / * + PARALLEL * /.

    IN demo_hdr_trgt, SELECT id, tstdata.demo_hdr_stg amt

    LOG ERRORS IN tstdata. ERR$ (run_name) _demo_HDR_STG

    REJECT LIMIT UNLIMITED;

    v_rowcount: = number of lines sql %;

    INSERT into demo_result_tab (run_name, v_module, v_action, rowcount) values (run_name, v_module, v_action, v_rowcount);

    commit;

    exception when others then

    dbms_output.put_line(SQLCODE||) e '|| SQLERRM);

    v_sqlcode: = sqlcode;

    v_sqlerrm: = sqlerrm;

    insert into demo_error_tab (run_name, v_module, v_action, sqlcode, sqlerrm, call_stack) values (run_name, v_module, v_action, v_sqlcode, v_sqlerrm, dbms_utility.format_call_stack);

    commit;

    -dbms_scheduler to analyze the error table and send e-mail

    end;

    end demo_hdr_pkg

    /

    -test

    declare

    v_runname varchar2 (100): = to_char (sysdate, 'YYYY_MM_DD_HH24_MI_SS');

    Start

    demo_hdr_pkg.hdr_ldr (v_runname);

    end

    /

    Select * from demo_hdr_stg by id

    /

    Select * from demo_hdr_trgt by id

    /

    Select * from demo_error_tab

    /

    Select * from demo_result_tab

    /

    This question is asked almost every day...

    http://martincarstenbach.WordPress.com/2010/05/27/the-difference-between-a-direct-grant-and-a-role-in-PLSQL/

    Summary, you need a DIRECT grant (not through a role), or you could modify the procedure to use the rights of the appellant (the default is rights define).

    See you soon,.

  • Why we need to create the package instead of procedure or function in Oracle

    Hello

    Recently, I attended an interview, they asked,
    why we must create the package instead of procedure or function in oracle. Is a specific advantage, if we create together.
    I'm not sure. can u tell me please someone.

    Thank you and best regards,
    Sanjeev.

    Hello

    A part of the oracle documentation.

    What is a PL/SQL Package?
    A package is a schema object which includes subroutines, variables, and logically related PL/SQL types. Packages have two parts: a specification (spec) and a body. Sometimes, the body is unnecessary. The specification is the interface to the package. It declares the types, variables, constants, exceptions, cursors, and subprograms that can be referenced from outside the package. The body defines queries for the sliders and the code for the subprogrammes.

    Benefits of the PL/SQL Packages
    Packages have a long history in software engineering, offering important characteristics for a reliable, maintainable, and reusable code, often in team for large systems development efforts.

    Modularity

    Packages allow you to logically encapsulate Associates types, elements, and subroutines in a module named PL/SQL. Each package is easy to understand, and the interfaces between packages are simple, clear and well defined. This facilitates the development of applications.

    Easier application design

    When you design an application, all you need initially is the interface information in the package specification. You can code and compile a spec without his body. Stored subprograms that reference the package can then be compiled as well. You should not set the package body entirely until you are ready to complete the application.

    Information masking

    With packages, you can specify which types, elements, and subprogrammes are (and accessible) public or private (hidden and inaccessible). For example, if a package contains four subprogrammes, three can be public and one private. The package hides the implementation of the subprogramme private so that only the package (not your application) is affected if the application changes. This simplifies maintenance and improvement. Also, by hiding the implementation details of the users, you protect the integrity of the packaging.

    Feature added

    Sliders and packed public variables persist for the lifetime of a session. They can be shared by all the subprogrammes that are running in the environment. They allow you to manage data in any of the transactions without storing in the database.

    Best performance

    When you call a subprogram packaged for the first time, the whole package is loaded into memory. Subsequent calls to related subprograms in package require no disk i/o.

    Packets stop cascading dependencies and avoid an unnecessary recompilation. For example, if you change the body of a packaged function, Oracle does not recompile other routines that call the function; These routines only depend on parameters and return value that are declared in the specification, so they are recompiled only if the specification changes.

  • Creating a package

    Hello
    CREATE OR REPLACE PACKAGE EMPDETAILS_PG AS
    
    TYPE RCT1 IS REF CURSOR;
    
    procedure get_empdetails
    (
    p_empno                   in number,
    P_refcursor_out          in out RCT1
    );
    
    END EMPDETAILS_PG; 
    CREATE OR REPLACE PACKAGE BODY EMPDETAILS_PG AS
    
    procedure get_empdetails
    (
    p_empno                   in varchar2,
    p_refcursor_out          in out RCT1
    ) 
    IS
    
    v_empno number := p_empno;
    BEGIN
    
    open p_refcursor_out for 
    select 
    EMPNO,
    ENAME,
    JOB,
    MGR,
    HIREDATE,
    SAL,
    COMM,
    DEPTNO from parisiemp where empno = v_empno;
    
    close p_refcursor_out;
    
    End get_empdetails;
    
    END EMPDETAILS_PG; 
    I get the error message like "PLS-00323: subprogram or cursor"GET_EMPDETAILS"is declared in a package specification and must be defined in the package body.

    Please help solve this problem.

    Thank you
    Gregory

    In package specifications

    procedure get_empdetails
    (
    p_empno number,
    P_refcursor_out in the RCT1
    );

    In the package body

    procedure get_empdetails
    (
    p_empno in varchar2,
    p_refcursor_out in the RCT1
    )

    Your first p_empno parameter is of a different data type. This is incorrect.

  • How to grant access to a package body to another user in execution

    Hello

    I have a package body that contains a single procedure and the owner of this APPS package.

    I have a requirement to grant access to this procedure which is inside the package to the user 'XXX' so that I can execute this procedure of user XXX in execution.

    When I tried under statement then it grant access to the package spec, not to the body. Please let me know how to give access to the package running body?
    Grant execute on KEI_TEK_IB_INTF_PKG to XXX.

    Thank you!

    PL, ensure that simultaneous program code is fully eligible package being called (i.e. APPS.) KEI_TEK_IB_INTF_PKG). If the scheme qualifier is omitted, you must create a public synonym (for example to create a public synonym KEI_TEK_IB_INTF_PKG for applications. KEI_TEK_IB_INTF_PKG) for this to work as expected.

    HTH
    Srini

  • ORA-04063: package body 'SYS. DBMS_LOGMNR_INTERNAL"contains errors

    Dear all,

    On my production server database RAC node 2, with 11 GR 2 and Linux is the operating system.

    Last month, I created a new tablespace and set it up as a logminer tablespace by using the command:
    EXECUTE DBMS_LOGMNR_D.SET_TABLESPACE ('TBS_LOGMINER');

    Today morning I accidentally dropped the TBS_LOGMINER tablespace and don't have any backup of the tablespace.

    Now when I recreate the tablespace and run the command:

    EXECUTE DBMS_LOGMNR_D.SET_TABLESPACE ('TBS_LOGMINER');

    It returns the following error:

    ERROR on line 1:
    ORA-04063: package body 'SYS. DBMS_LOGMNR_INTERNAL"contains errors
    ORA-06508: PL/SQL: called program unit is not found:
    * "SYS. DBMS_LOGMNR_INTERNAL. "
    ORA-06512: at "SYS." DBMS_LOGMNR_D', line 135
    ORA-06512: at line 1

    Even when I tun and expdp exp
    For exp ORA-04063: package body 'SYS. DBMS_LOGREP_UTIL"contains errors
    For expdp
    ORA-04063: package body 'SYS. DBMS_INTERNAL_LOGSTDBY"contains errors
    ORA-06508: PL/SQL: called program unit is not found: 'SYS. DBMS_INTERNAL_LOGSTDBY ".
    ORA-06512: at "SYS." "KUPV$ FT", line 991
    ORA-04063: package body 'SYS. DBMS_LOGREP_UTIL"contains errors
    ORA-06508: PL/SQL: called program unit is not found: 'SYS. DBMS_LOGREP_UTIL ".

    I tried to compile objects disabled utlrp.sql running, but it did not help.

    Its my production environment and I doubt that I could have run catalog.sql and catproc.sql that can cause other problems as well.

    Please guide how to pass through this error.

    Kind regards
    Imran
    Its my production environment and I doubt i might have to run catalog.sql and catproc.sql that may cause other problems as well.
    

    Why? You manipulated SYS?
    running catalog.sql and catproc.sql in a normal situation only takes time and nothing else.

    ---------
    Sybrand Bakker
    Senior Oracle DBA

  • 3.1EA1 members of the package body are not not in the tree

    The problem is when you develop the package specification or body package tree, not all members of the body/specification are listed.

    Probably in connection with
    Re: 3.1EA2 corrected a bug even non - members of the body of the package are not not in the tree
    but do not know if this variant will be covered by the patch.

    The example in this case is with the UNPIVOT operator syntax (which uses a FOR...) UNDER construction but is not a PL/SQL loop).
    CREATE OR REPLACE PACKAGE Test_Package1 AS
    --
      PROCEDURE Test;
    --          
    END Test_Package1;
    /
    CREATE OR REPLACE PACKAGE BODY Test_Package1 AS
      PROCEDURE TEST IS
        
        /*
        CURSOR c_1 IS
          SELECT t1,t2,t3
          FROM
             (SELECT NULL nl, 1 one, 2 two, 3 three FROM dual)
          UNPIVOT ( (t1, t2, t3)
                    FOR dt_type IN (
                     (one,   nl,   nl) AS 'A',
                     (nl,    two,  nl) AS 'B',
                     (nl,    nl,   three)  AS 'C'
                    )
                  );
        */
        CURSOR c_2 IS
          SELECT t1,t2,t3
          FROM
             (SELECT NULL nl, 1 t1, 2 t2, 3 t3 FROM dual);
      BEGIN
        FOR r_rec in c_2 LOOP
          dbms_output.put_line(r_rec.t1);
        END LOOP;
      END;
    END Test_Package1;
    /
    Comment out the c_1 cursor and the TEST procedure is displayed in the browser. Uncomment and get lost

    Published by: Gary Myers on 13/12/2011-14:34

    Published by: Gary Myers on 13/12/2011-14:35

    «.. . Commenting on the first slider allows the TEST... »

    As does turn PIVOT UNPIVOT :-) Fixed

  • creating a package in sql * more

    Hello all;

    Do you know what the problem with that statement
    SQL> create or replace pkg_initial_comment as procedure save_initial_comment(p_i
    d number, p_first_name varchar2, p_last_name varchar2, p_comment varchar2, p_dat
    e date); end save_initial_comment; create or replace package body pkg_initial_co
    mment as procedure save_initial (p_id number, p_comments varchar2, p_first_name
    varchar2, p_last_name varchar2, p_date date) is begin insert into initial_commen
    ts values (1, p_first_name, p_last_name, p_comment, sysdate); end save_initial;
    end pkg_initial_comment;
    create or replace pkg_initial_comment as procedure save_initial_comment(p_id num
    ber, p_first_name varchar2, p_last_name varchar2, p_comment varchar2, p_date dat
    e); end save_initial_comment; create or replace package body pkg_initial_comment
     as procedure save_initial (p_id number, p_comments varchar2, p_first_name varch
    ar2, p_last_name varchar2, p_date date) is begin insert into initial_comments va
    lues (1, p_first_name, p_last_name, p_comment, sysdate); end save_initial; end p
    kg_initial_comment
    I get the following error message

    ORA-00922:

    and my table structure is less than
    create table initial_comment (id number(30),
    first_name varchar2(4000), last_name varchar2(4000), create_date date);

    're missing you the keyword package after first replace.

    Good bye
    DPT

Maybe you are looking for

  • Understand what I would be buying

    I downloaded Toshiba BT Stack to test with a USB dongle not - Toshiba a Win7Pro, 64-bit. First impressions are very good, and I plan to buy the battery. It is not clear to me, however, exactly what I would like to buy. By clicking on the product lice

  • Ability to record HD on Android 2.2?

    Hello. I have a small question Update 2.2 European will give US 720 p recording on our Motorola Defy? Thanks for the reply

  • 9033 OR &amp; NI 9870 - series recording parameters do not restart the cRIO.

    Hello I have a cRIO OR 9033 with two RS232 9870 cards. The two cards series and their ports do not appear when I turn on the cRIO. When I run my executable in real time, once it crashes, saying: he cannot find the ports I ask. After that it crashes,

  • OfficeJet Pro k550: copy print task Quick Sets of Win7 for Win10

    Put PC from Windows 7 to Windows 10.  After that, all my custom Print Quick Sets Taks disappeared.  I have a picture of my old installation of Windows 7.  Can someone tell me where are stored the these quick sets and if it is possible to copy them fr

  • Acer aspire 5732z wait almost exactly a minute at the start

    I have an acer aspire laptop 5732z (now Windows 10) as I'd first of all several years ago was a delay of 1 minute at the start (but usually not re - starts). If I turn it on closing down the blue disk activity light flashes - and then he lowers very