Package Spec

1. what is the purpose of creating bodyless package ? what are the advantages of creating like this ?
2. what is the reason for using "CREATE OR REPLACE PACKAGE" instead of dropping and creating ?

Balarenganathan wrote:
1. what is the purpose of creating bodyless package ? what are the advantages of creating like this ?Here's one example of a user for creating a bodyless package...
Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
And if you want to know how to prevent discarded package states....
Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
  2  /
Table created.
SQL>
SQL> insert into dependonme values (5)
  2  /
1 row created.
SQL>
SQL> create or replace package mypkg is
  2    procedure myproc;
  3  end mypkg;
  4  /
Package created.
SQL>
SQL> create or replace package body mypkg is
  2    v_statevar number := 5; -- this means my package has a state
  3
  4    procedure myproc is
  5      myval number;
  6    begin
  7      select x
  8      into myval
  9      from dependonme;
10
11      myval := myval * v_statevar;
12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13    end;
14  end mypkg;
15  /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        VALID
SQL>
SQL>
SQL> alter table dependonme add (y number)
  2  /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        INVALID
SQL>
SQL> exec mypkg.myproc
BEGIN mypkg.myproc; END;
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SCOTT.MYPKG" has been invalidated
ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.MYPKG"
ORA-06512: at line 1
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        INVALID
SQL>
SQL> exec mypkg.myproc
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
SQL> drop table dependonme
  2  /
Table dropped.
SQL>
SQL> drop package mypkg
  2  /
Package dropped.
SQL>
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
  2  /
Table created.
SQL>
SQL> insert into dependonme values (5)
  2  /
1 row created.
SQL>
SQL> create or replace package mypkg is
  2    procedure myproc;
  3  end mypkg;
  4  /
Package created.
SQL>
SQL> create or replace package mypkg_state is
  2    v_statevar number := 5; -- package state in seperate package spec
  3  end mypkg_state;
  4  /
Package created.
SQL>
SQL> create or replace package body mypkg is
  2    -- this package has no state area
  3
  4    procedure myproc is
  5      myval number;
  6    begin
  7      select x
  8      into myval
  9      from dependonme;
10
11      myval := myval * mypkg_state.v_statevar;  -- note: references the mypkg_state package
12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13    end;
14  end mypkg;
15  /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        VALID
SQL>
SQL> alter table dependonme add (y number)
  2  /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
  2  /
OBJECT_NAME
OBJECT_TYPE         STATUS
MYPKG
PACKAGE             VALID
MYPKG
PACKAGE BODY        INVALID
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.The other uses are of course that you just want to create a load of type definitions etc. to be used by multiple packages elsewhere. ;)
2. what is the reason for using "CREATE OR REPLACE PACKAGE" instead of dropping and creating ?What's the reason for dropping and recreating when you've got the option to create or replace? ;)

Similar Messages

  • Wants Some Help About Package Spec

    Hi Friends,
    I developed one package spec in my Report.
    It has around 40 Ref Cursors.
    I created 40 Functions for those Ref Cursors.
    Right now all are in my Report at client end.
    At present the performance is very slow.
    Can i maintain these Package spec & Functions
    in data base side? If possible how ?
    If i maintain like that my performance is
    increases or not?

    You should be able to move those to the server. Read Chapter 6 in Oracle Report Documentation. Just click on topic "Documentation" on your left to find documentation on report.

  • Schema name not present on filename for "Save Package Spec and Body"

    In versions previous to 3.0 EA, the filename defaulted to schema.object.sql when using the "Save Package Spec and Body" on the right click of the package/body. This appears to have disappeared. Also, it now defaults to the .PLS ext/type, which I prefer to save them as .SQL (which i can override, but it would be nice in the file type dropdown). Also, I had posted a suggestion about the actual file not including the schema name prefixing the object name when using the "Save Package Spec and Body". i.e. it does create or replace package reader_package instead of what it should be doing which is create or replace package schema.reader_package

    Would be nice indeed having the real name as default, and all supported PL/SQL types (as in the preferences) in the extensions dropdown.
    As for the schema name inside, I reckon that would do damage for more users than it would do good for others. But a preference would be best of course.
    K.

  • Problem with "Package Spec" please help.

    Hello once again.
    I'm developing a master-detail form, so I'm using a "Package Spec" variable to hold the primary key value from the master form. The primary key value for the master is generated by a sequence.
    Here's the package spec:
    PACKAGE primary_keygen IS
    pkey varchar2(15); 
    END;Now the master table has the following "Before Insert" Trigger .
    CREATE OR REPLACE TRIGGER MASTER_NUM_GEN
    BEFORE INSERT
    ON MASTER
    FOR EACH ROW
    DECLARE
    primary_key_value varchar2(15);
    BEGIN
    select lpad(to_char(ref_gen.nextval), 4,'0')
    into primary_key_value from dual;
    primary_keygen.pkey:='ABC/'||primary_key_value;
    :new.Ref_Number:=primary_keygen.pkey;
    END;For the detail block. I have the following "Before Insert Trigger" to generate the primary key values.
    CREATE OR REPLACE TRIGGER DET1_NUM_GEN
    BEFORE INSERT
    ON DETAIL1
    FOR EACH ROW
    BEGIN
    if :new.M_ref_number is NULL THEN
    :new.M_ref_number:=primary_keygen.pkey;
    ENd if;
    END;Works quite fine if I have only one detail block. But if I have multiple detail blocks. Depending on the user's selection. i.e. After entering data into the master block, the user selects a detail block ('Letter type'- using stacked canvases for this purpose and radio buttons for selecting the view) and then Inserts data into it. here's what I do in the Detail block2.
    CREATE OR REPLACE TRIGGER OREF_NUM_GEN
    BEFORE INSERT
    ON DETAIL2
    FOR EACH ROW
    BEGIN
    if :new.O_ref_number is NULL THEN
    :new.O_ref_number:=pkey_gen.master_key;
    ENd if;
    END;Now the problem is that When I enter one record into detail1, works fine, but for the second time, when I try to insert another record. the master table gets a new reference number (primary key value) while the detail block gets the previous value that was used in the first record!, so that means 'pkey_gen.master_key' is holding the old value, while in my opinion it should hold the new value, I dont know whats wrong here. If I try to insert two consecutive records into the same detail table, I get an error saying "Unique Constraint voilated", becuase the variable is holding the old values.
    And lastly after it inserts the record into the database, I get a dialog box saying, "successfuly inserted 2 records into the database" and when I click ok, the Form closes by itself, any ideas on how to stop this?
    I'm really stuck here. Please help me out on this.
    Thanks.
    Note: I'm using Form6i with Database 10g.
    Message was edited by:
    fahimkhan82

    Hi,
    Maybe the best way to start is to try building a new form from scratch. For simplicity I will assume that you have one master and one detail table. Master table has a primary key and the detail table has a foreign key to the master. Based on this, with the forms you can create a database block based on your master table. Use the wizard. Again using the wizard, create a second block based on the detail table. You'll see a screen to prompt to create a relationship. Create one by selecting the master table and the right foreign key relation. Now take a close look to all triggers automatically created by the form. Also check the "Relations" object found in you master block object tree. Note that the foreight key column in the detail table has the "Copy Value From Item" property set to monitor the master block's primary key.
    This is the basic. You don't need the database triggers, except (in case you want to insert through, say, SLQPlus) the one for the master table, which will look like this:
    CREATE OR REPLACE TRIGGER MASTER_NUM_GEN
    BEFORE INSERT
    ON MASTER
    FOR EACH ROW
    BEGIN
    IF :new.ref_number IS NULL THEN
    select 'ABC/'||pad(to_char(ref_gen.nextval), 4,'0')
    into :new.ref_number
    from dual;
    END IF;
    END;
    Now you have to take care about the inserts in your form. Create PRE-INSERT trigger on the master block.
    IF :master.ref_number IS NULL THEN
    SELECT 'ABC/'||pad(to_char(ref_gen.NEXTVAL), 4,'0')
    INTO :master.ref_number
    FROM dual;
    END IF;
    Run the form and explore different situations to see how the form is keeping the data integrity.
    Compile with Shift+K (incremental). Sometimes forms blow just because not all of the trigers were compiled properly.
    Hope this helps...

  • Report cannot access pl/sql table variable defined in Package Spec.

    Hi,
    I've created a package spec called pkg_report with a PL/SQL table variable defined called body_text_table. When I tried to compile the following code under the Before Report trigger:
    :desc := pkg_report.body_text_table(1);
    Oracle gave me the following error:
    Implementation Restriction: 'PKG_REPORT.BODY_TEXT_TABLE': Cannot directly access remote package variable or cursor.
    Does anyone have any idea about this error? Thank you for your time at looking at it.
    Regards,
    John

    You cannot directly access the package variable in a database package. The work around is to create a set_variable and get_variable wrapper function in the package body. See Metalink note 105838.1 for more info.
    A simple example:
    create or replace package my_package as
      my_var     number;
      function   get_variable return number ;
      procedure  set_variable (p_value in number) ;
    end ;
    create or replace package body my_package as
      function get_variable return number is
      begin
        return my_var;
      end ;
      procedure set_variable(p_value in number) is
      begin
        my_var := p_value ;
      end ;
    end;

  • Copying Packaging Spec

    When I am copying packaging spec, the fields  'Category', 'Sub-Category' & 'Group' are getting copied over, however the fields under 'Available UOM', 'UOM Conversions' and Cross Reference' are not getting copied, whether I choose to keep the copied Spec linked to the Template or not. [Both the Spec copied from and the Template used has those UOM/Cross reference fields defined] . Aren't those UOM/Cross reference fields suppose to be copied over to the new Spec?  When I create a new Spec from Template, system brings over all fields [UOM/Cross reference etc.] from Template, so I was expecting the same behavior while copying too, since I am linking to the Template during the copying process. Can someone shed some light on this issue please?

    I believe that the functional use cases are different. When you are copying from a Template, you are not copying a real existing specification - rather, you are creating a spec with values that should be there by default. These values from a template are typically not meant to be specific to one single specification, but rather to a grouping/classification of specs. Perhaps a Beverage type specification, created from a Beverage template, would have certain Available UOMs that a Sauce specification would not. Cross References on a template may be used for pack size purposes, which may also be specific to a template.
    When you copy an existing specification, the assumption is that the specification is linked to some external system(s) using the cross references - if those were copied over, you could have an possible discrepancy. Also, since you are doing a copy and not a new revision, we assumed the UOM info would be different so is is cleared out.

  • Bug SQL Developer 3.0.04 Save Package Spec and Body to ips file bug

    Hi.
    I have problem with export package body end header. Exported ips file have some rows switched compared to original source code.
    SQL Developer version: 3.0.04. Build MAIN-04.34
    Error simulation:
    - Click on package header with right mouse button in SQL Developers Connections bar
    - In context menu choose 'Save Package Spec and Body...'
    - Save ips file... (Small bug: Offered file name is wrong (= last saved package/file, not actual name of package) :-( )
    - This file(source code) compare with original source code in Developer and u will see switched rows every +-90. row in source code.
    Can u fix this in next version of SQL Developer?
    Thanks...
    Edited by: 880809 on 22.8.2011 6:57

    Bug 12904494 has been created.
    Michael

  • Split a PL/SQL Package Spec and Body

    I hope this was not discussed in some other thread somewhere (haven't found it), but my problem is:
    How to split the Package Spec and Package Body in JDeveloper if you want to have both (for database deployment) as files in e.g. a subversion repository?
    The problem arises if you have a couple of packages that are dependent on each other, so that you have to deploy the specs first to have the "public" part in place and afterwards the bodies to define the package functions/procedures.
    Is there a way to do this?
    TIA.
    --Ciao, FD.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    If you want to store for example the package "mypackage" source code in a subversion repository
    one possibility is to define 2 svn files:
    - mypackage.pks (which contains the package "specification") and
    - mypackage.pkb ( package "body").
    I haven't tried this from JDev 11.2 but it works for example when using a single-user
    svn repository from Sql Developer 2.1.1. ( in SQL Dev if you specify a database
    connection you can compile the file based pakage specification and after then the
    package body ...)
    Regards
    user_alex

  • How to retreive contents of package spec and body over jdbc

    is there a query i can issue that would return the contents (both spec and body) of a database package? similar to "desc schema.pkg" ?
    i want to issue this query via jdbc and get back the contents of the package spec/body.

    solved:
    select * from user_source where name='my_pkg'
    Message was edited by:
    user612126

  • Can we declare a Cursor in Package Specs?

    Dear buddies
    Can I Declare a Cursor in Package Specs so that I can call that cursor and use its data in some procedures and functions of package. Otherwise I've to write that cursor for every sub-program of a package which I don't feel a smart way to accomplish the job.

    Hi,
    here is a short example with the whole way down. Maybe the concept is getting clearer with this:
    first of all, if you do not have the table emp, here the DDL for this example.
    Be carefull, works only for german clients because of the names of months, sorry for that.
    CREATE TABLE EMP
    (EMPNO NUMBER(4) NOT NULL,
    ENAME VARCHAR2(10),
    JOB VARCHAR2(9),
    MGR NUMBER(4),
    HIREDATE DATE,
    SAL NUMBER(7, 2),
    COMM NUMBER(7, 2),
    DEPTNO NUMBER(2));
    set echo on
    INSERT INTO EMP VALUES
    (7369, 'SMITH', 'CLERK', 7902,
    TO_DATE('17-DEZ-1980', 'DD-MON-YYYY'), 800, NULL, 20);
    INSERT INTO EMP VALUES
    (7499, 'ALLEN', 'SALESMAN', 7698,
    TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600, 300, 30);
    INSERT INTO EMP VALUES
    (7521, 'WARD', 'SALESMAN', 7698,
    TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30);
    INSERT INTO EMP VALUES
    (7566, 'JONES', 'MANAGER', 7839,
    TO_DATE('2-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20);
    INSERT INTO EMP VALUES
    (7654, 'MARTIN', 'SALESMAN', 7698,
    TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30);
    INSERT INTO EMP VALUES
    (7698, 'BLAKE', 'MANAGER', 7839,
    TO_DATE('1-MAI-1981', 'DD-MON-YYYY'), 2850, NULL, 30);
    INSERT INTO EMP VALUES
    (7782, 'CLARK', 'MANAGER', 7839,
    TO_DATE('9-JUN-1981', 'DD-MON-YYYY'), 2450, NULL, 10);
    INSERT INTO EMP VALUES
    (7788, 'SCOTT', 'ANALYST', 7566,
    TO_DATE('09-DEZ-1982', 'DD-MON-YYYY'), 3000, NULL, 20);
    INSERT INTO EMP VALUES
    (7839, 'KING', 'PRESIDENT', NULL,
    TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10);
    INSERT INTO EMP VALUES
    (7844, 'TURNER', 'SALESMAN', 7698,
    TO_DATE('8-SEP-1981', 'DD-MON-YYYY'), 1500, 0, 30);
    INSERT INTO EMP VALUES
    (7876, 'ADAMS', 'CLERK', 7788,
    TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20);
    INSERT INTO EMP VALUES
    (7900, 'JAMES', 'CLERK', 7698,
    TO_DATE('3-DEZ-1981', 'DD-MON-YYYY'), 950, NULL, 30);
    INSERT INTO EMP VALUES
    (7902, 'FORD', 'ANALYST', 7566,
    TO_DATE('3-DEZ-1981', 'DD-MON-YYYY'), 3000, NULL, 20);
    INSERT INTO EMP VALUES
    (7934, 'MILLER', 'CLERK', 7782,
    TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10);2. Package Spec:
    create or replace
    package test_cursor as
      --Type for the returncode of the function
      TYPE typ_emp IS TABLE OF emp%rowtype;
      --Array for fetching, of course also possible in the body
      t_emp typ_emp;
      --function wich returns the array from fetching the cursor
      function get_emp return typ_emp;
      --function for manupilation data retrieved by the function
      PROCEDURE man_emp;
    end test_cursor;3. Package Body
    create or replace
    package body test_cursor as
      FUNCTION get_emp RETURN typ_emp AS
      cursor c_emp is select * from emp;
      BEGIN
        open c_emp;
        fetch c_emp BULK COLLECT INTO t_emp;
        CLOSE c_emp;
        --t_emp returns the whole table set from emp
        return t_emp;
      end get_emp;
      PROCEDURE man_emp AS
      --just for not confusing names, is the same as t_emp of course
      v_emp_array typ_emp;
      BEGIN
        --call the function and retrieve the whole data set
        v_emp_array := get_emp;
        --now manipulate the data, in this case just write the names to the calling client
        FOR rec IN v_emp_array.FIRST .. v_emp_array.LAST
        loop
          dbms_output.put_line(v_emp_array(rec).ename);
        end loop;
      end man_emp;
    end test_cursor;4. Calling the procedure
    SET serveroutput ON
    exec test_cursor.man_emp;5. And this is the result:
    anonymer Block abgeschlossen
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLERPlease be aware, this is just for demonstration purpose, of course it makes no sense to display the names this way. But how to call a funktion returning arrays with datasets from fetching cursors is shown here.
    Hth
    Joerg

  • Bulk Export Package Spec and Body as single file

    Is there a way to bulk export the package spec and body into a single file, you can export spec and body if you choose each individual proc/package but if you just choose the spec/body individually from the connection - > packages list it only exports that part of the code. If not i will raise as an enhancement.
    Thanks
    Trotty

    Thanks for your update K.
    Have tried that and you can sort of do it however you still have to choose/select the spec/body individually so twice the overhead selescting them.
    Will raise an enhancement and see where it goes.
    Thanks
    Trotty

  • Define userdefined types in package spec

    perfectly working userdefined in one schema when brought in to package spec of another schema give me an error:
    Error(26,6): PLS-00540: object not supported in this context.
    I am looking for some rules to follow when decalring types in a package specifications.
    Thank you

    See following section of PL/SQL User's Guide and Reference http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/10_objs.htm#4139
    that says:
    Currently, you cannot define object types in a PL/SQL block, subprogram, or package
    The list of types that can be created in a package specification seems to be:
    - subtype: http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/03_types.htm#3359
    - collections: http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm#19661
    - record:
    http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm#7543
    - ref cursor:
    http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96624/06_ora.htm#1554
    Not sure that this is the full list because I did not find a complete list in one PL/SQL document.
    Message was edited by:
    Pierre Forstmann

  • Saving package spec and body

    In previous versions of SQL Developer, there was always an All Files option in the dropdown when saving package spec and body. Now we're using the latest version 3.1.07.42 and the only option available is to save as a .pls extension. We do not use .pls files in our system, and it's annoying to have to save as .pls and then copy the code into another file. Does anyone know a way around this, and also why Oracle has put such a restriction on the save function?

    Hi,
    Welcome to the forum. This behavior of the chooser UI for Save Package Spec and Body changed between 3.0 and 3.1, mostly for the better, I assume, except perhaps for the issue on which you comment. In general, I believe there was an effort to make the user experience more consistent across the product when opening or saving files.
    Checking this area in the code line up next for release, I see that pls and sql are the file extension choices, but not all files. Will that help?
    Regards,
    Gary
    SQL Developer Team

  • EA2 - Export Wizard - No forward slash after package spec and body in sql

    I exported a schema with the export wizard. My stand alone functions and sql types in the script have have a forward slash after the "end;" statement Great. However, package specs and body create statements do not have a forward slash after the "end;" and I believe they also should have this.

    This appears to be a DB issue as we are just using DBMS_METADATA to generate the ddl. Please test manually using worksheet or sqlplus
    exec DBMS_METADATA.SET_TRANSFORM_PARAM( DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR' , TRUE );
    select dbms_metadata.get_ddl('PACKAGE', 'PACKAGE_NAME','SCHEMA') from dual;
    I looked through the DB bugs briefly and noticed a few on other objects that were fixed in 9.2.0.6 but I didn't see one for Packages...
    This is not something I would fix in SQL Developer as the core issue is with DBMS_MEATADATA and your version of the DB.
    As this is fixed in 10 I'm sure you can work with support and request a backport if it's not a currently available patch.

  • Reg: Package Spec and Body

    All,
    I am adding a function to an existing package. I have added the function code only in the package body and compiled. I have received the below error.
    PLS-00313: 'Fun_check' not declared in this scope
    Where as, I have declared the same function in the package specification, then no issues.
    So, my question is, Can't we add the function/procedure without the declaration of it inside the package specification.Because,I see,  there were many functions inside the same package body, which were not declared in the package specification.  What will happen,  if we declare the function/proc  inside the package spec and what if not.
    Thanks in advance.
    Thanks,

    EV259 wrote:
    PLS-00313: 'Fun_check' not declared in this scope
    For this error need to define the local programs before these being called by another program in package body.
    Check below example for giving proper scope to local program in package body.
    create or replace package p1
    as
    procedure p1;
    function f1 return number;
    end p1;
    create or replace package body p1
    as
    procedure p1
    is
    var number;
    begin
      null;
      var := f_l;  -- first:- calling local f_l before defining will throw error
    end;
    function f_l   --second:- defining local f_l
    return number
    is
    begin
         null;
      return 2;
    end;
    function f1
    return number
    is
    begin
       null;
       return 1;
    end;
    end p1;
    Warning: Package Body created with compilation errors.
    SQL> show err
    Errors for PACKAGE BODY P1:
    LINE/COL ERROR
    8/3      PL/SQL: Statement ignored
    8/10     PLS-00313: 'F_L' not declared in this scope
    ------ Now Creating scope for local function f_l through out pkg body by defining it first!
    create or replace package body p1
    as
    ------- can be called in any program below it
    function f_l
    return number
    is
    begin
         null;
      return 2;
    end;
    procedure p1
    is
    var number;
    begin
      null;
      var := f_l;
    end;
    function f1
    return number
    is
    begin
       null;
       return 1;
    end;
    end p1;
    Package body created.

  • Save package spec and body in lower case ?

    I'm using sqldeveloper 3.1.07. We have the convention to save all source files in lower case. However, when I do "Save package spec and body" the filename that is suggested is always upper case. Is there a setting for this that I missed or any way I can change this ?

    Buntoro,
    thank you very much - that worked just fine (if I start from the Tools menu and then can select only the packages and package body options - and then in the next step do the name filtering for the selected objects).
    I was trying to use shift key and select multiple packages from the browser and then unload - that does not give you the "package body" selection option. In that particular case, the related package bodies for the selected packages should be automatically included - but I don't know if that can be classified as a bug or even an improvement, given that this can be achieved from the Tools menu (then unload).
    I understand what you mean by
    ========================================================
    "Note that the Package Spec displays only the choosen ones.
    But, why on earth unloading all of package body instead of the ones which we chose before?
    Simply forward, the output of this caused all of the package body to be exported.
    So please be aware before using this."
    ========================================================
    I also believe this is a bug and needs to be fixed.
    Buntoro, thanx again.
    R/ Zaf
    Edited by: zaferaktan on Jan 12, 2011 10:57 AM

Maybe you are looking for

  • The volume on the second half of my Quicktime slideshow fades out--and I don't want it to do that!

    I used FotoMagico 4.0 to make a slideshow. There are options for exporting, and I chose the one called Custom, which makes a Quicktime movie. For some reason the volume in the second half of the show starts to fade out, and by the end I can barely he

  • Error when submitting any form  (ALC-WKS-007-043)

    I am getting the following error any time I submit a form using the "Complete" button inside the workspace. An error occurred submitting the form (task xxx, form {1}). (ALC-WKS-007-043) I have restarted the server and still get the same error! Any id

  • Can't view/load movies in iMovie

    I'm on ios 6.0.1. First time iMovie user. Synched two movies to my iPad2, one from my iPhone5 another from my BlackBerry. I can view both in the Videos app. But I cannot load them in iMovie, I just get a black window. Photos and music are OK.

  • Locking div's, banners, and background images

    Hello! I'm trying to figure out how to lock a background image and banner around my body content using div's but am not sure how. When scrolling I would like only the Header Bar and Body section to move, while the background image and banner always s

  • SCM-- Live cache trace on

    Hi Experts , Recently I have encountered one issue in my SCM system .There was trace on in live cache due to that system's performance very slow and CPU utilisation was more than 80%. I have checked in LC10 but i didnot find is trace on or off .I hav