Comparisons of Packages vs Object Types

Hi all,
I wonder if anyone can point me towards any articles or documentation that compares/contrasts the advantages and disadvantages of Packages against Object Types?
For example, I like the ability to have private variables and procedures within Packages but don't know how I achieve the same thing with Object Types so a comparison of the two styles would be very useful.
Thanks all,
Leo

Hmmm. As far as I can tell, these are 2 different animals. The way I look at it
- A package is a grouping of one or more variables, procedures and functions. It is a PL/SQL construct.
- An object type is a type definition that may be used to declare SQL and PL/SQL constructs.
I would refer you to the docs at http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14260/toc.htm (under the 10gR2 doc set at http://tahiti.oracle.com, "Application Development" tab) for a good source of information related to your question.

Similar Messages

  • Packaging custom Objects TYPE

    Hello everybody,
    i wonder if it is possible to "package" objects into package definition as follow:
    CREATE OR REPLACE PACKAGE OBJECTS_TEST IS
    TYPE MYTYPE IS OBJECT(T0 VARCHAR2(200),T1 VARCHAR2(200));
    when i try to execute this I always receive the following error:
    ERROR line 3, col 22, ending_line 3, ending_col 22, Found '(', Expecting: ;
    So far, seems that the definition of the object must go internally to the PACKAGE BODY, therefore into a FUNCTION/PROCEDURE.
    I would like to define a package that works as a global handler for all my objects used in my schema, what I'm supposed to do ?
    Any help will be very appreciated,
    Thank you,
    Luigi

    Thank you everybody for your support, and as requested I'll try to be more precise.
    I'm developing functions and procedure to manipulate data that will then be used by a Business Object universe.
    As for now, I've opted to develop some custom transformation procedure in PL/SQL to handle special cases where strings contains value pairs like :
    1~FirstText~2~SecondText
    From this point onward, I need to create a view that needs to be like this:
    VALUE | TEXT
    1 | FirstText
    2 | SecondText
    So far, I've build a PL/SQL procedure that parse the string and returns a TABLE OF OBJECTS to be further used in a VIEW with more or less 100 records.
    Those objects where initially declared externally to my package in this way:
    CREATE OR REPLACE TYPE RadioQuestionParam IS OBJECT (
                                                Q_ID     VARCHAR2 (50 CHAR),
                                                Q_F_ID  VARCHAR2 (50 CHAR),
                                                Q_VALUE VARCHAR2 (4000 CHAR),
                                                Q_TEXT  VARCHAR2 (4000 CHAR)
    CREATE OR REPLACE TYPE RadioQuestionParamTable IS TABLE OF RadioQuestionParam;
    /and the procedure that will use them is...
    create or replace package objects_test
    FUNCTION PARAMS2ROWS2     (P_Q_ID      IN  VARCHAR2,
                                 P_Q_F_ID    IN  VARCHAR2,
                                P_Q_PARAM   IN  VARCHAR2)
                                RETURN RadioQuestionParamTable ; 
    end objects_test;
    /so then I can use:
    select * from table(objects_test.params2rows2('q_id','q_f_id','1~TEST1~2~TEST2'));to produce the desired output.
    As I would like to organize everything in one single package I was wondering if there's a way of using OBJECTS INSIDE A PACKAGE....
    As for now I've modified my code to use michaels2 suggestion but with no luck as when I execute the
    select * from table(objects_test.params2rows2('q_id','q_f_id','1~TEST1~2~TEST2')); I'm receiving a ORA-00902: invalid datatype;
    Thank you for your precious help,
    Luigi

  • Different EBS Adapter interfaces generate same object types differently

    Hi,
    We are experiencing the following behavior when using two different interfaces that are both generated from the E-Business Suite Adapter.
    Wrapper packages and object types are generated and created in the database. But in both cases the generator creates a type called gme_api_pub_rowtype_sql1.
    Alas, that same type has a different specification depending on the interface. Hence, one of the api's has compile errors as it expects the type to have additional parameters.
    Has anyone experienced the same behavior?
    More important: is there a way to overcome the problem?
    Thanks, Sjoerd

    To add to that:
    We are not willing to have separate schemas for each of the EBS Adapter interfaces so that we can have multiple instances / occurrences of type gme_api_pub_rowtype_sql1, i.e. one per schema.
    This would quickly turn into a maintenance nightmare.
    Thanks, Sjoerd

  • Declare object type inside the package

    Hi,
    How can I declare an object type inside the package?
    CREATE TYPE TempObj AS OBJECT (
    user_id number,
    text varchar2(4000),
    date_created DATE
    This will not work if placed inside this:
    CREATE OR REPLACE PACKAGE SAMPLE_PKG IS
    ---declaration goes here.
    END SAMPLE_PKG;
    I tried using the type RECORD and it worked. But I am just curious how to declare an Object. Or maybe RECORD is the replacement of Object? is this correct?
    thanks,
    Baldwin

    The inside of a PL/SQL package should contain PL/SQL statements.
    CREATE TYPE is not a PL/SQL statement. You can't create a table in package either.
    If data protection is the reason that you would rather create the type inside the package, then consider using a record type as you suggested, or hiding the SQL type in a more protected schema.
    Message was edited by:
    jonjac

  • Can you reference package variables in a pl/sql object type

    I'm trying to create an object type and I would like to use a type from a pacakge definition as one of the parameters for a method in the object. I read that types defined inside a PL/SQL package cannot be used as parameter. Does anyone have a workaround for this?

    You could move the type definition out from the package to a schema level object type. Then you should be able to use the schema level object type in both your package and the new object you wish to create.
    Below is a short example of what I mean:
    -- The way I interpreted your question
    CREATE OR REPLACE PACKAGE foo_pkg
    AS
    TYPE foo_obj IS RECORD (
    f1 NUMBER
    ,f2 VARCHAR2 (10)
    in_pkg_foo_obj foo_obj;
    END foo_pkg;
    SHOW errors
    CREATE OR REPLACE TYPE newFooObj IS OBJECT (
    f1 NUMBER
    ,f2 VARCHAR2 (3)
    ,f3 DATE
    ,MEMBER FUNCTION getAllFoos (inFoo IN foo_pkg.foo_obj)
    RETURN NUMBER
    SHOW errors
    CREATE OR REPLACE TYPE BODY newFooObj
    AS
    MEMBER FUNCTION getAllFoos (inFoo IN foo_pkg.foo_obj)
    RETURN NUMBER
    IS
    BEGIN
    RETURN 1;
    END;
    END;
    SHOW errors
    -- Clean up
    DROP PACKAGE foo_pkg;
    DROP TYPE newFooObj;
    -- Now try it with a schema level object type
    CREATE OR REPLACE TYPE foo_obj IS OBJECT (
    f1 NUMBER
    ,f2 VARCHAR2 (10)
    CREATE OR REPLACE PACKAGE foo_pkg
    AS
    in_pkg_foo_obj foo_obj;
    END foo_pkg;
    SHOW errors
    CREATE OR REPLACE TYPE newFooObj IS OBJECT (
    f1 NUMBER
    ,f2 VARCHAR2 (3)
    ,f3 DATE
    ,MEMBER FUNCTION getAllFoos (inFoo IN foo_obj)
    RETURN NUMBER
    SHOW errors
    CREATE OR REPLACE TYPE BODY newFooObj
    AS
    MEMBER FUNCTION getAllFoos (inFoo IN foo_obj)
    RETURN NUMBER
    IS
    BEGIN
    RETURN 1;
    END;
    END;
    SHOW errors
    DROP PACKAGE foo_pkg;
    DROP TYPE newFooObj;
    Bob

  • SSIS 2012 - Parent/Child Package "Object" Type Variables

    How do I pass Variables of Object type from Parent to Child packages?
    I am using the SSIS 2012 project deployment model.
    Thanks

    You can do it as outlined in
    http://sqlblog.com/blogs/andy_leonard/archive/2010/01/25/ssis-snack-passing-parent-starttime-to-the-child-package.aspx
    But
    When you need an object it is typically a recordset, then just pass the results, or execute the query in a package.
    Arthur My Blog

  • What target property must be specified while passing a object type variable to child package in SSIS 2012

    What target property must be specified while passing a object type variable to child package in SSIS 2012???

    As shown below, there is variable strVar and it's Value property is selected. Likewise you have to select the property that you need to pass.
    Please refer:
    http://www.bidn.com/blogs/MikeDavis/ssis/155/passing-variable-values-from-parent-package-to-child-ssis
    -Vaibhav Chaudhari

  • Transport of a package object type DEVC

    Hello,
    when I create a transport task manually with package (object type DEVC) in SE10, does it
    a) only transport the package definition again
    or
    b) transport the package and all the objects in it?
    Thanks in advance for your help!

    Hi,
    When you transport the package it transports the package and all the objects in it.
    Regards,
    Renu

  • Can't access packaged object type in Java

    Hi
    I am getting the following error while accessing an oracle packaged object type. Can You please give me an advise..!!
    java.sql.SQLException: invalid name pattern: XXGW_RMA_CREATION_PKG.XXGW_RMA_RECRegards

    HI
    I am not asking how to search in google. If You know how to resolve my problem..then help me. I don't what this kind of answers.
    This is my problem
    Error in java.
    java.sql.SQLException: invalid name pattern: XXGW_RMA_CREATION_PKG.XXGW_RMA_REC
    This is my package
    create or replace package xxgw_rma_creation_pkg
    is
    type xxgw_rma_rec is record (dealer_name varchar2(40), dealer_desc varchar2(300));
    type xxgw_rma_line is table of xxgw_rma_rec; --(item_name varchar2(40), item_desc varchar2(300)) index by binary_integer;
    xx_rma_rec  xxgw_rma_rec;
    xx_rma_line xxgw_rma_line
    procedure xxgw_rma_creation (p_rma_rec in xxgw_rma_rec ,p_rma_line in xxgw_rma_line,p_rma_no out varchar2);
    end;
    create or replace package body xxgw_rma_creation_pkg
    is
    procedure xxgw_rma_creation (p_rma_rec in xxgw_rma_rec ,p_rma_line in xxgw_rma_line,p_rma_no out varchar2)
    is
    l_rma_rec xxgw_rma_rec := p_rma_rec;
    l_rma_line xxgw_rma_line := p_rma_line;
    begin
    dbms_output.put_line(l_rma_rec.dealer_name||'  '||l_rma_rec.dealer_desc);
    for i in  l_rma_line.first..l_rma_line.last loop
    dbms_output.put_line(l_rma_line(i).dealer_name||'  '||l_rma_line(i).dealer_desc);
    end loop;
    p_rma_no := '20';
    end;
    end;Rekha

  • Unit test for object types

    In the current version (2.1.0.63) I can perform only unit test for packages, function and procedures. But we use a lot of object types in the database and would like to test them. Is there any support for object types scheduled?

    You can also use the original UT PLSQL package from sourceforge.
    I have used this in the past for testing with file comparisons, table object output from procedures, etc.
    We've also used the same setup for Oracle Forms code testing.
    Dennis

  • DB Adapter - Calling Stored Procedure with Object Type

    So, we are using JDeveloper 10.1.3.3
    We are trying to create an ESB process that invokes a SP with an object type. However, the owner of the package / SP, is NOT the owner of the object type. When going through the DB Adapter wizard, it gives us the following error:
    When attempting to use the DB Adapter in JDeveloper to create a partner link to execute a stored procedure. JDeveloper returns the following error:
    Unable to import WSDL.
    Error while writing wsdl file
    Database type is either not supported or is not implemented.
    Check to ensure that the type of the parameter is one of the supported datatypes or that there is a collection or user defined type definition representing this type defined in the database.
    However, if I create a wrapper package / SP, it works just fine. I'd really like to not be having to create wrapper code for these SPs to work. Is this resolved in 11g? Is there a patch available for 10.1.3.3?
    I think this is a JDeveloper Wizard issue, but thought I'd post this here as well.
    Thanks,
    BradW

    This problem can be resolved by granting execute permission on the object type to the caller. For example, if the stored procedure is in schema1 and the object type is in schema2 then you would connect as schema2 and execute
    SQL> grant execute on <object type> to schema1
    Referencing object types defined in other schemas is documented. This is the described method for accessing object types in other schemas.

  • How can we execute a procedure with object type as its parameter, by passing partial elements.

    Can somebody help...
    I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
    PROCEDURE p_save (example IN OUT xyz_obj)
    my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
    And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.

    user13026549 wrote:
    Can somebody help...
    I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
    PROCEDURE p_save (example IN OUT xyz_obj)
    my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
    And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.
    It ISN'T possible. How could it be? Each attribute has to be set to something don't you think?
    A common way to handle that is to define a public package variable that is an instance of the object type and has ALL elements set to null. As Odie suggested a custom constructor function can be used for that.
    Then you create your procedure instance by starting with an instance of the package variable (where everything is null) and setting values for the attributes you need.

  • How to call a Oracle Proc,which contains Object Type as in Param, from java

    Hi
    Would like to know how to call a Oracle Procedure which contains the Object Type Parameter from java.
    Here is my code will look like...
    1. CREATE OR REPLACE TYPE emp AS OBJECT
    Empno NUMBER,
    Ename VARCHAR2(50)
    [COLOR=royalblue]In step1 I have created object type.[COLOR]
    2.CREATE OR REPLACE PACKAGE ref_pkg IS
    TYPE tab_emp IS TABLE OF emp;
    END ref_pkg;
    [COLOR=royalblue]In step2,I have created a table type which is of type emp;[COLOR]
    3. CREATE OR REPLACE PROCEDURE p_emp(p_emptab IN ref_pkg.tab_emp) as
    BEGIN
    FOR I IN 1..p_emptab.COUNT
    LOOP
    Some code written here
    END LOOP;
    END;
    [COLOR=royalblue]In step3 I have passed tabletype which is of type emp as argument.[COLOR]
    Now I need to invoke this procedure from JAVA.
    Calling a procedure doesn�t matter.
    But how I can map objecttype ? how will java recognize oracle object ?
    How can I implement this ?
    Any Help/Clues is Appreciated.
    Thanks
    Krishna

    Hi Bob
    You can call a stored proc from a database control with the jc:sql annotation itself.
    Assume a stored proc taking one In parameter
    * @jc:sql statement="call sp_updateData({id})"
    void call_sp_updateCust(int id);
    You can even call stored proc with OUT parameters using
    * @jc:sql statement="{call sp_MyProc(?, ?)}"
    void call_sp_MyProc(SQLParameter[] params)
    You can also call stored functions via db control.
    More info and diff ways to call at
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/database/conStoredProcedures.html
    Thanks
    Vimala

  • Oracle Object Types vs. Table Fields

    Hello, all.
    I`m totally new to Oracle, and I am facing a very hard problem for me, and I would like to ask your help.
    I've been working on a project which uses Oracle Object Types, from a database of a legacy system.
    I did not know Oracle Objects until 5 minutes ago, so sorry If I say something stupid:
    Per my understanding, a Oracle Object Type can be formed by fields like myField varchar(200)... and fields from an existing table or view.
    I have a lot of objects on my system and I need to map each field and its respective table or view that compose each object.
    Does anyone have a query for that? I think it should be common, but I could not find anything at google (maybe I don`t which terms use to find...)
    I would be very thankful if somebody could help (save) me.
    Thanks in advance.
    Paulo

    First, it would help if you post what you object types look like.
    I'm assuming they may look something like this:
    SQL> create TYPE emp_type AS OBJECT
      2    (emp_id   NUMBER,
      3     name VARCHAR2(20));
      4  /
    Type created.
    SQL> create TYPE emp_tab IS TABLE OF emp_type;
      2  /
    Type created.
    SQL> create or replace package emp_test as
      2  procedure get_emps;
      3  end emp_test ;
      4  /
    Package created.
    SQL> create or replace package body emp_test as
      2    employees emp_tab := emp_tab();
      3    procedure get_emps as
      4      g_rc sys_refcursor;
      5  BEGIN
      6    employees.EXTEND(2);
      7    employees(1) := emp_type (1, 'John Smith');
      8    employees(2) := emp_type (2, 'William Jones');
      9    OPEN g_rc FOR
    10    SELECT * FROM TABLE (CAST (employees AS emp_tab));
    11  END get_emps ;
    12  end emp_test ;
    13  /
    Package body created.

  • Member function and member procedure inside an object type in Oracle.

    Hi All,
    Please do have a look at these codes and help me understand. I have no idea about this member function and member procedure. How do they work? Please explain me about this.
    Regards,
    BS2012
    create type foo_type as object (
      foo number,
      member procedure proc(p in number),
      member function  func(p in number) return number
    create type body foo_type as
      member procedure proc(p in number) is begin
        foo := p*2;
      end proc;
      member function func(p in number) return number is begin
        return foo/p;
      end func;
    end;
    /

    Methods are just like functions or procedures in a package, except they're not in a package, their part of an object type.
    The object has attributes (which are the variables declared in it).
    To use such an object you would do things like this...
    SQL> set serverout on
    SQL>
    SQL> declare
      2    v_foo foo_type;
      3    v_val number;
      4  begin
      5    v_foo := foo_type(20); -- instantiate the object and initialize the object attributes
      6    v_foo.proc(20); -- call the object method (proc)
      7    v_val := v_foo.func(4); -- call the object method (func)
      8    dbms_output.put_line(v_val);
      9  end;
    10  /
    10
    PL/SQL procedure successfully completed.The Type definition you've declared creates the object class, but not actually an object itself.
    To actually have an object you need to declare a variable of that object class type, and then instantiate it. When you instantiate the object you need to initialize all the attributes (generally you can pass null if required for each of them to initialize them).
    Once you have your object instantiated, you can call the methods within that object as demonstrated above, a bit like calling functions and procedures in a package, except they are methods within the object type itself, and therefore called directly by referencing them from the variable.
    The documentation goes into a lot more detail of objects if you look it up.

Maybe you are looking for