Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2007
    Posts
    1

    Question Unanswered: PL/SQL Packages Question

    Hi,

    This is my first time trying to create a package.

    I am struggling to get it to compile and run and need some help. When running/compiling it in Toad v9, get the following errors:

    PLS-00905: object IVOR.SAP is invalid
    PLS-00304: cannot compile body of 'SAP' without its specification
    Lastly PL/SQL: Compilation unit analysis terminated.

    This whole package may be gibberish, however I would appreciate a little help

    Many thanks Mango


    CREATE OR REPLACE PACKAGE SAP AS
    PROCEDURE MyProcedure(obatchno out string,ibatchno in string,oinvoicenum out string, iinvoicenum in string);
    END SAP;
    /

    CREATE OR REPLACE PACKAGE body SAP AS
    /************************************************** ****************************
    NAME: SAP
    PURPOSE:

    REVISIONS:
    Ver Date Author Description
    --------- ---------- --------------- ------------------------------------
    1.0 22/11/2007 1. Created this package.
    ************************************************** ****************************/

    PROCEDURE MyProcedure(obatchno out string,ibatchno in string,oinvoicenum out string, iinvoicenum in string) is
    strbatchno varchar2(100);
    strinvoicenum varchar2(100);
    Begin
    select aibatch_.BATCHNUMBER, aibatch_.INVOICENUMBER
    into
    strbatchno,
    strinvoicenum
    from aibatch_;

    obatchno := strbatchno;
    oinvoicenum := strinvoicenum;

    update aibatch_
    set batchnumber = ibatchno,
    invoicenum = iinvoicenum;
    commit;

    END MyProcedure;
    END SAP;
    /

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Learn how to use TOAD so that you could help yourself and us.

    When viewing packages (and procedures and functions), there's the "ERROR" tab in the right side of the Schema Browser. Refresh the screen and check what you've done wrong so that package didn't compile.

    Good, old SQL*Plus on Oracle 10g doesn't complain about package specification nor its body (I've left out code you used as I don't have those tables and was lazy to create them, which is supposed to be YOUR part of the job - to provide testing environment, including CREATE TABLE and INSERT INTO sample data statements):
    Code:
    SQL> CREATE OR REPLACE PACKAGE Sap AS
      2    PROCEDURE MyProcedure(obatchno OUT string, ibatchno IN string,
      3                          oinvoicenum OUT string, iinvoicenum IN string);
      4  END Sap;
      5  /
    
    Package created.
    
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY Sap AS
      2
      3    PROCEDURE MyProcedure(obatchno OUT string, ibatchno IN string,
      4                          oinvoicenum OUT string, iinvoicenum IN string)
      5    IS
      6      strbatchno VARCHAR2(100);
      7      strinvoicenum VARCHAR2(100);
      8    BEGIN
      9      NULL;
     10    END MyProcedure;
     11
     12  END Sap;
     13  /
    
    Package body created.
    
    SQL>
    Which Oracle database version do you use? What happens if you run this code via SQL*Plus? If there are any errors, type
    Code:
    SQL> SHOW ERRORS
    and post the result back here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •