Varray of Object Type

Hello,
I am still very new at PL/SQL so please bare with me if you can. I am trying to learn how to store data from an object in a single varray of objects. My code below is attempting to declare an object type with 3 instance attributes and 3 instance methods of getter and setter method.
Then i want to create a varray type to store an array of "Employee" object types.
From here i am trying to use a loop to retrieve the first 10 ename, empno, and sal records from the emp table and store them in the variable array of 10 elements.
Finally, I tried to use another loop to output the ename, empno, and sal in reverse order.
My object and my object body was created successfully with no errors.
The problem starts when I begin the anonymous block that creates the varray, this is where i get an error message at the end.
At the end of my code is the error message i get. Can anyone suggest to me what I am doing wrong, and/or what I can do to achieve this task.
SET SERVEROUTPUT ON
--create object
CREATE OR REPLACE TYPE Employee AS OBJECT(
  ename_obj VARCHAR2(10),
  empno_obj NUMBER(4),
  sal_obj NUMBER(7,2),
  MEMBER FUNCTION getename RETURN VARCHAR2,
  MEMBER FUNCTION getempno RETURN NUMBER,
  MEMBER FUNCTION getsal RETURN NUMBER);
--create object body
CREATE OR REPLACE TYPE BODY Employee AS
  MEMBER FUNCTION getename RETURN VARCHAR2 IS
  BEGIN
   RETURN ename_obj;
  END;
  MEMBER FUNCTION getempno RETURN VARCHAR2 IS
  BEGIN
   RETURN empno_obj;
  END;
  MEMBER FUNCTION getsal RETURN VARCHAR2 IS
  BEGIN
   RETURN sal_obj;
  END;
END;
--create varray of object and begin line 1 of ERROR Message--
1> DECLARE
2> TYPE tvrEmploy IS VARRAY(10) OF Employee;
3>  vClient    tvrEmploy;
4>    iCounter   integer:=1;
5>   CURSOR client_cursor IS
6>   SELECT ename, sal
7>    FROM emp
8>    WHERE rownum < 11;
9>  BEGIN
10>    vClient:=tvrEmploy(null,null,null,null,null,null,null,null,null,null) ;
11>    FOR i IN client_cursor LOOP
12>       vClient(iCounter).ename_obj:=i.ename;
13>      vClient(iCounter).empno_obj:=i.empno;
14>       vClient(iCounter).sal_obj:=i.sal;
15>       iCounter:=iCounter+1;
16>    END LOOP;
17>    FOR I IN REVERSE 1..10 LOOP
18>        dbms_output.put_line(to_char(I) ||' '|| vClient(I).ename_obj ||' '|| vClient(I).empno_obj ||' '||
          vClient(I).sal_obj);
19>    END LOOP;
20> END ;
21> /
--ERROR message below--
DECLARE
ERROR at line 1:
ORA-06530: Reference to uninitialized composite
ORA-06512: at line 12
Thank you again for your time and patience.
-Todd

Hi,
The error occurs on line 12, the first time through the loop, when you try to execute:
vClient(iCounter).ename_obj:=i.ename;
At that point, vClient (1) is not an Employee object; it's NULL.
Try this:
DECLARE
    TYPE tvrEmploy IS VARRAY(10) OF Employee;
    vClient    tvrEmploy;
    iCounter   integer := 1;
    CURSOR client_cursor IS
        SELECT  ename, sal
        ,       empno                                                 -- ADDED
   FROM    scott.emp
   WHERE   rownum < 11;
BEGIN
    vClient := tvrEmploy (null,null,null,null,null,null,null,null,null,null) ;  
    FOR i IN client_cursor LOOP
        vClient (iCounter) := Employee (i.ename, i.empno, i.sal);     -- CHANGED
        iCounter := iCounter + 1;
   END LOOP;
FOR I IN REVERSE 1..10 LOOP
       dbms_output.put_line(to_char(I) ||' '|| vClient(I).ename_obj ||' '|| vClient(I).empno_obj ||' '||
      vClient(I).sal_obj);
   END LOOP;
END ;

Similar Messages

  • Problem in fetching varray of Object type

    Below are the code,
    where am calling an procedure which returns me Varray of object type test_obj(id number, name varchar2);
    Am facing an problem in get the object(test_obj) from ARRAY object
    the exception is java.lang.ClassCastException: java.lang.Object
    at line number No 12..
    Can anyone suggest me How handle this...
    1. STRUCT test_objStruct ;
    2. ARRAY test_arr;
    3. OracleCallableStatement cs = (OracleCallableStatement)
    4. con.prepareCall("{call test_data(?)}");
    5. cs.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.ARRAY,"TEST_ARR");
    6. cs.execute();
    7. test_arr = (ARRAY)cs.getObject(1);
    8.System.out.println("array varible "+test_arr.getBaseTypeName());
    9. System.out.println("length "+test_arr.length());
    10. Map map = (Map)con.getTypeMap();
    11. map.put("TEST_OBJ", Class.forName("oracle.sql.STRUCT"));
    12. test_objStruct = (STRUCT)test_arr.getArray(1,1);
    13.Object country_attrs[] = test_objStruct.getAttributes();
    14.System.out.println ("ID: " country_attrs[0]);
    15.System.out.println ("Name: " +country_attrs[1]);
    the output is..
    array varible TEST_OBJ
    length 106
    Error java.lang.ClassCastException: java.lang.Object

    Hi,
    The error occurs on line 12, the first time through the loop, when you try to execute:
    vClient(iCounter).ename_obj:=i.ename;
    At that point, vClient (1) is not an Employee object; it's NULL.
    Try this:
    DECLARE
        TYPE tvrEmploy IS VARRAY(10) OF Employee;
        vClient    tvrEmploy;
        iCounter   integer := 1;
        CURSOR client_cursor IS
            SELECT  ename, sal
            ,       empno                                                 -- ADDED
       FROM    scott.emp
       WHERE   rownum < 11;
    BEGIN
        vClient := tvrEmploy (null,null,null,null,null,null,null,null,null,null) ;  
        FOR i IN client_cursor LOOP
            vClient (iCounter) := Employee (i.ename, i.empno, i.sal);     -- CHANGED
            iCounter := iCounter + 1;
       END LOOP;
    FOR I IN REVERSE 1..10 LOOP
           dbms_output.put_line(to_char(I) ||' '|| vClient(I).ename_obj ||' '|| vClient(I).empno_obj ||' '||
          vClient(I).sal_obj);
       END LOOP;
    END ;

  • Cannot query varray of object types-please help

    I am attempting to query the "diminfo" field of the view "MDSYS.all_sdo_geom_metadata". The field is "described" as MDSYS.SDO_DIM_ARRAY, which I believe is a varray of MDSYS.SDO_DIM_ELEMENT.
    I have run OTT to generate the class files, but nothing is generated for the MDSYS.SDO_DIM_ARRAY "type" (maybe because it's not really a type?). A class is generated for the SDO_DIM_ELEMENT objects.
    Anyway, I have tried to query the field using both "VALUE(diminfo)" and "REF(diminfo)":
    select VALUE(diminfo) from all_sdo_geom_metadata;
    - or -
    select REF(diminfo) from all_sdo_geom_metadata;
    and I get back an ORA-904 "invalid identifier". When I remove the "VALUE" or "REF" from the query, the error goes away, and is replaced by an ORA-32162 "Read/Write method not registered" further down in the code when I try to retreive the value from the recordset:
    myDimInfo = rSet->getObject(1);
    Since the field type (MDSYS.SDO_DIM_ARRAY) isn't really an object type, I can see why the "Read/Write method not registered" occurs-there are no methods to register.
    Can someone provide a code snippet of how to perform this query?
    Thanks in advance

    Hi,
    I am using OTT generated objects to pass them to my PL/SQL procedures as OUT parameters. When I call the registerOutParam() function, I get this error ORA-32162: Read/Write SQL method not registered.
    I am calling my mapping function after creating environment and before creating my stateless connection pool. But still I am getting this exception at runtime while calling registerOutParam().
    Environment* env;
    env = Environment::createEnvironment(Environment::OBJECT);
    MessageTOMapping(env); // Calling the mapping function here.
    // Creating the stateless connection pool.
    StatelessConnectionPool* scp;
    scp = env->createStatelessConnectionPool("naveen",
    "naveen",
    "//10.105.153.11:1521/pls",
    10,
    5,
    2,
    StatelessConnectionPool::HOMOGENEOUS);
    // Fetch a connection from the stateless connection pool
    conn = scp->getConnection();
    // After this, I create my Statement and call the registerOutParam() which
    // causes ORA-32162 exception.
    Please note that I do not get this error when I don't use any connection-pooling mechanism. That is, if I create an environment in OBJECT mode, call the mapping function with its pointer and create a normal Connection object (without any pooling etc), my application runs perfectly fine. E.g. if I replace the above piece of code with the code below, my application runs fine.
    Environment* env;
    env = Environment::createEnvironment(Environment::OBJECT);
    MessageTOMapping(env); // Calling the mapping function here.
    conn = env->createConnection("naveen", "naveen", "//10.105.153.11:1521/pls");
    // After this, I create my Statement and call the registerOutParam() which
    // does not give problem now and my application runs pefectly fine.
    Can anyone let me know what I am doing wrong while using the stateless connection pooling mechanism? I definitely need to use Stateless Connection Pooling and must not get connections directly from env->createConnection().
    Any help will be greatly appreciated.
    Thanks and Regards,
    Naveen

  • How to index a varray of object type?

    Hello,
    Is it possible to index a varray/Table type, which is of type of an object, like the way the scalar types are.
    say, CREATE OR REPLACE
    TYPE SAMPLE_TABLE AS TABLE OF Date index by binary_integer
    But if I have to change the table type from Date to an object
    lets say
    create or replace TYPE SAMPLE_TYPE AS OBJECT (
    id NUMBER(12),
    value varchar2(12)
    Will I be able to do
    CREATE OR REPLACE
    TYPE SAMPLE_TABLE AS TABLE OF SAMPLE_TYPE index by id
    If not, is there a way it can be done, or is it a limitaion that it cant be done. Any pointers to this is highly appreciated.
    Thanks

    One way to do this...
    SQL> drop type profile_options_object_array
      2  /
    SQL> drop type profile_options_object
      2  /
    SQL> drop table t
      2  /
    SQL>
    SQL> CREATE OR REPLACE TYPE profile_options_object AS OBJECT(
      2  option_name VARCHAR2(100),
      3  option_value VARCHAR(200)
      4  );
      5  /
    SQL> CREATE OR REPLACE TYPE profile_options_object_array AS VARRAY(32000) OF profile_options_object;
      2  /
    SQL>
    SQL> create table t
      2  (x varchar2(10)
      3  ,y varchar2(10)
      4  );
    SQL> insert into t values ('name1', 'value1');
    SQL> insert into t values ('name2', 'value2');
    SQL> commit;
    SQL>
    SQL> select profile_options_object (x, y)
      2    from t
      3  /
    PROFILE_OPTIONS_OBJECT(X,Y)(OPTION_NAME, OPTION_VALUE)
    PROFILE_OPTIONS_OBJECT('name1', 'value1')
    PROFILE_OPTIONS_OBJECT('name2', 'value2')
    SQL> declare
      2     profile_options  profile_options_object_array;
      3     idx pls_integer;
      4  begin
      5     select profile_options_object (x, y)
      6       bulk collect
      7       into profile_options
      8       from t
      9     ;
    10    idx := profile_options.first;
    11    while idx is not null
    12    loop
    13      dbms_output.put_line (profile_options(idx).option_name); 
    14      dbms_output.put_line (profile_options(idx).option_value);
    15      idx := profile_options.next(idx);
    16    end loop;
    17  end;
    18  /
    name1
    value1
    name2
    value2
    SQL>

  • TYPE OR TABLE DEPENDENCY OF OBJECT TYPE (ORA-2303)

    제품 : SQL*PLUS
    작성날짜 : 2004-05-20
    ==================================================
    TYPE OR TABLE DEPENDENCY OF OBJECT TYPE (ORA-2303)
    ==================================================
    PURPOSE
    Type이나 table의 dependency가 있는 type을 drop하거나 replace하고자
    하면 ORA-02303 error가 난다. 이 error의 원인을 알아보도록 한다.
    Explanation
    Object의 attribute나 method를 수정하기 위해서는 object type을 drop하고 재생성
    해야 한다. Type이나 table의 dependency가 있는 type을 drop하거나 replace하고자
    하면 ORA-02303 error가 난다. Object type은 type (nested table 또는 VARRAY)
    또는 object table로써 구체적으로 표현된다. 만약 data의 보존이 필요하다면
    temporary table에 manual하게 옮겨놓아야 한다.
    SQL Reference guide에 의하면 DROP TYPE FORCE 옵션은 recommend하지 않는다.
    왜냐하면 이 옵션을 쓰게 되면 복구가 불가능하고 dependency가 있던 table들은
    access하지 못하는 결과를 초래한다.
    Example
    아래의 query 1, 2, 3은 dependency을 확인하는 query문이다.
    1. Find nested tables
    select owner, parent_table_name, parent_table_column
    from dba_nested_tables
    where (table_type_owner, table_type_name) in
    (select owner, type_name
    from dba_coll_types
    where elem_type_owner = '<typeOwner>'
    and elem_type_name = '<typeName>');
    2. Find VARRAYs
    select owner, parent_table_name, parent_table_column
    from dba_varrays
    where (type_owner, type_name) in
    (select owner, type_name
    from dba_coll_types
    where elem_type_owner = '<typeOwner>'
    and elem_type_name = '<typeName');
    3. Find object tables
    select owner, table_name
    from dba_object_tables
    where table_type_owner = '<typeOwner>'
    and table_type = '<typeName>'
    and nested = 'NO';
    Example ) Logon as Scott
    /* Create an user defined object type */
    SQL> create type object_type as object (
    col1 number,
    col2 varchar2(20))
    Type created.
    /* Create nested table type */
    SQL> create type object_ntable as table of object_type
    Type created.
    /* Create varray type*/
    SQL> create type object_varray as varray(5) of object_type
    Type created.
    /* Create parent table with nested table and varray */
    SQL> create table master (
    col1 number primary key,
    col2_list object_ntable,
    col3_list object_varray)
    nested table col2_list store as master_col2
    Table created.
    /* Create object table */
    SQL> create table object_table of object_type (col1 primary key)
    object id primary key;
    Table created.
    ORA-2303 results if attempt to drop type with dependencies
    SQL> drop type object_type;
    drop type object_type
    ERROR at line 1:
    ORA-02303: cannot drop or replace a type with type or table dependents
    위의 queery 1,2,3을 이용하여 object type dependency을 확인한다.
    -- Find nested tables utilizing object type
    SQL> select owner, parent_table_name, parent_table_column
    from dba_nested_tables
    where (table_type_owner, table_type_name) in
    (select owner, type_name
    from dba_coll_types
    where elem_type_owner = 'SCOTT'
    and elem_type_name = 'OBJECT_TYPE');
    OWNER PARENT_TABLE_NAME PARENT_TABLE_COLUMN
    SCOTT MASTER COL2_LIST
    -- Find VARRAYs utilizing object type
    SQL> select owner, parent_table_name, parent_table_column
    from dba_varrays
    where (type_owner, type_name) in
    (select owner, type_name
    from dba_coll_types
    where elem_type_owner = 'SCOTT'
    and elem_type_name = 'OBJECT_TYPE');
    OWNER PARENT_TABLE_NAME PARENT_TABLE_COLUMN
    SCOTT MASTER COL3_LIST
    -- Find object tables
    SQL> select owner, table_name
    from dba_object_tables
    where table_type_owner = 'SCOTT'
    and table_type = 'OBJECT_TYPE'
    and nested = 'NO';
    OWNER TABLE_NAME
    SCOTT OBJECT_TABLE
    참고)
    bulletin : 11576 처럼 utility을 이용하는 방법이 있다.
    우리는 여기서 주의하여야 할 것은 script $ORACLE_HOME/rdbms/admin/utldtree.sql
    을 내가 보고자 하는 user에서 돌려야 한다는 것이다.
    $sqlplus scott/tiger
    SQL> @$ORACLE_HOME/rdbms/admin/utldtree.sql
    SQL> exec deptree_fill('TYPE','SCOTT','OBJECT_TYPE');
    PL/SQL procedure successfully completed.
    SQL> select * from ideptree;
    DEPENDENCIES
    TYPE SCOTT.OBJECT_TYPE
    TYPE SCOTT.OBJECT_NTABLE
    TABLE SCOTT.MASTER
    TYPE SCOTT.OBJECT_VARRAY
    TABLE SCOTT.MASTER
    TABLE SCOTT.MASTER_COL2
    TABLE SCOTT.OBJECT_TABLE
    Reference Documents
    Korean bulletin : 11576
    <Note:69661.1>

    Hi Carsten,
    Thanks for the sharp hint. It works.
    However, when I create a table using the schema, it gives me this error:
    varray DOC."LISTOFASSIGNEDNUMBER"."ASSIGNEDNUMBER"
    ERROR at line 14:
    ORA-02337: not an object type column
    Here is the script:
    CREATE TABLE CUSTOMMANIFEST (
    ID NUMBER PRIMARY KEY,
    DOC sys.XMLTYPE
    xmltype column doc
    XMLSCHEMA "http://www.abc.com/cm.xsd"
    element "CustomManifest"
    varray DOC."LISTOFMANIFESTPORTINFO"."MANIFESTPORTINFO"
    store as table MANIFESTPORTINFO_TABLE
    (primary key (NESTED_TABLE_ID, ARRAY_INDEX))
    organization index overflow
    varray DOC."LISTOFASSIGNEDNUMBER"."ASSIGNEDNUMBER"
    store as table ASSIGNEDNUMBER_TABLE
    (primary key (NESTED_TABLE_ID, ARRAY_INDEX))
    organization index overflow
    LISTOFASSIGNEDNUMBER itself is complexType and not sure where is the error....
    You may note there are more than two hierachy/levels...
    Thanks.

  • Invoking stored procedure that returns array(oracle object type) as output

    Hi,
    We have stored procedures which returns arrays(oracle type) as an output, can anyone shed some light on how to map those arrays using JPA annotations? I tried using jdbcTypeName but i was getting wrong type or argument error, your help is very much appreciated. Below is the code snippet.
    JPA Class:
    import java.io.Serializable;
    import java.sql.Array;
    import java.util.List;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import org.eclipse.persistence.annotations.Direction;
    import org.eclipse.persistence.annotations.NamedStoredProcedureQuery;
    import org.eclipse.persistence.annotations.StoredProcedureParameter;
    * The persistent class for the MessagePublish database table.
    @Entity
    @NamedStoredProcedureQuery(name="GetTeamMembersDetails",
         procedureName="team_emp_maintenance_pkg.get_user_team_roles",
         resultClass=TeamMembersDetails.class,
         returnsResultSet=true,
         parameters={  
         @StoredProcedureParameter(queryParameter="userId",name="I_USER_ID",direction=Direction.IN,type=Long.class),
         @StoredProcedureParameter(queryParameter="employeeId",name="I_EMPLOYEEID",direction=Direction.IN,type=Long.class),
         @StoredProcedureParameter(queryParameter="TEAMMEMBERSDETAILSOT",name="O_TEAM_ROLES",direction=Direction.OUT,jdbcTypeName="OBJ_TEAM_ROLES"),
         @StoredProcedureParameter(queryParameter="debugMode",name="I_DEBUGMODE",direction=Direction.IN,type=Long.class)
    public class TeamMembersDetails implements Serializable {
         private static final long serialVersionUID = 1L;
    @Id
         private long userId;
         private List<TeamMembersDetailsOT> teamMembersDetailsOT;
         public void setTeamMembersDetailsOT(List<TeamMembersDetailsOT> teamMembersDetailsOT) {
              this.teamMembersDetailsOT = teamMembersDetailsOT;
         public List<TeamMembersDetailsOT> getTeamMembersDetailsOT() {
              return teamMembersDetailsOT;
    Procedure
    PROCEDURE get_user_team_roles (
    i_user_id IN ue_user.user_id%TYPE
    , o_team_roles OUT OBJ_TEAM_ROLES_ARRAY
    , i_debugmode IN NUMBER :=0)
    AS
    OBJ_TEAM_ROLES_ARRAY contains create or replace TYPE OBJ_TEAM_ROLES_ARRAY AS TABLE OF OBJ_TEAM_ROLES;
    TeamMembersDetailsOT contains the same attributes defined in the OBJ_TEAM_ROLES.

    A few things.
    You are not using a JDBC Array type in your procedure, you are using a PLSQL TABLE type. An Array type would be a VARRAY in Oracle. EclipseLink supports both VARRAY and TABLE types, but TABLE types are more complex as Oracle JDBC does not support them, they must be wrapped in a corresponding VARRAY type. I assume your OBJ_TEAM_ROLES is also not an OBJECT TYPE but a PLSQL RECORD type, this has the same issue.
    Your procedure does not return a result set, so "returnsResultSet=true" should be "returnsResultSet=false".
    In general I would recommend you change your stored procedure to just return a select from a table using an OUT CURSOR, that is the easiest way to return data from an Oracle stored procedure.
    If you must use the PLSQL types, then you will need to create wrapper VARRAY and OBJECT TYPEs. In EclipseLink you must use a PLSQLStoredProcedureCall to access these using the code API, there is not annotation support. Or you could create your own wrapper stored procedure that converts the PLSQL types to OBJECT TYPEs, and call the wrapper stored procedure.
    To map to Oracle VARRAY and OBJECT TYPEs the JDBC Array and Struct types are used, these are supported using EclipseLink ObjectRelationalDataTypeDescriptor and mappings. These must be defined through the code API, as there is currently no annotation support.
    I could not find any good examples or doc on this, your best source of example is the EclipseLink test cases in SVN,
    http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/plsql/
    http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/customsqlstoredprocedures/
    James : http://www.eclipselink.org

  • XDB Native Web Services - Collection of object types

    Hello,
    my DB 11g (11.1.0.6.0) is enabled to use XDB Native Web Services, everything works as it should. I already use it successfully to publish a web service with object types as OUT parameter. They are created as complex types in the XML response as described here: [http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb_web_services.htm#CHDGBFID]
    But what I need is a collection of these object types, e.g.
    I have a type FLIGHT with some information elements (departure, arrival, date, time, price) and I have a web service function GET_AVAILABILITY with parameters departure, arrival and date. What I want is to return a collection of FLIGHT objects, it could be none, one or many flights for a request.
    For the moment I create another object type which contains a fix number of FLIGHT objects to work around the collection issue:
    create flight_tab_typ as object (
    fl1 flight_typ
    ,fl2 flight_typ
    ,fl3 flight_typ
    I tried to build a PL/SQL table of object type and also a VARRAY of object type but for both the WSDL of the web service cannot be build up correctly in the web browser. For me it seems that this is not supported by the Native Web Services.
    I know I can build up my own XMLTYPE with XML structure as OUT parameter but to use object types is much easier and it builds up the XML structure automatically.
    Does anybody know how to use collections (VARRAY or PL/SQL Tables) with the Native XML DB Web Services?
    Thanks,
    Andreas

    Hi flea,
    I use complex types with XDB native webservices. Here is an example. Using people/groups objects. I haven't compiled this so there may be some typos etc, but it should give you the idea.
    Beware!I have had problems with the created WSDL file in that it doesn't always include the namespace from all types. In many client packages ( JDevloper , SOAPUI etc) this causes a wsdl import failure.
    You can add the missing namespace by hand a load the WSDL file locally and then it should work. I haven't raised an SR with Oracle about this yet.
    Assume you create the following under SCoTT schema on machine host.com on port 8080.
    The webservice[WSDL] will be available from
    http://host.com:8080/orawsv/SCOTT/WEBSERVCIES/GET_GROUP[?wsdl]
    For other peoples sanity it took me a little while to realise the WSDL url is case specific. E.g. the schema, package and functions have to be UPPER case.
    create table people_groups_tab (group_name varchar2(40 char),first_name varchar2(40 char),last_name varchar2(40 char))
    insert into people_groups_tab values ('FINANCE','Joe','Bloggs')
    insert into people_groups_tab values ('FINANCE','Bob','Jones')
    insert into people_groups_tab values ('IT','Alan','Andrews')
    create or replace type person_obj
    as object
         first_name people_groups_tab.first_name%type
         ,last_name people_groups_tab.last_name%type
    create or replace type people_obj
    as table of person_obj
    create or replace type people_groups_obj
    as object
    group_name varchar2(40 char)
    people people_obj
    create or replace package webservices
    as
              function get_group
         p_group_name varchar2
              ) return people_groups_obj;
    end;
    create or replace package body webservices
    as
              function get_group
         p_group_name varchar2
              ) return people_groups_obj
    as
    l_group people_groups_obj;
              l_people people_obj;
    begin
              select person_obj
                        first_name
                        ,last_name
              bulk collect into l_people
              from people_groups_tab
              where group_name p_group_name;
              l_group := people_groups_obj(p_group_name,l_people);
              return l_group;
    end;
    end;
    /

  • Varray, Nested Table and Object types in OWB r2

    Requirement:
    Flat file with repeating groups of nested content need to move into Object Relational ORACLE table (using varray or nested tables - no preference). The data will be loaded, then mapped/transformed into a richer O-R output to directly produce XML outputs.
    Problem:
    Generated PL/SQL "seems" to do the correct thing, but deployment errors show failures on mapping of collections (varrays, NTs or OTs) and in sqlplus recompiling the PKB still gives the errors. Is this a PL/SQL generator error, or is there a more meaningful example of using CONSTRUCT OBJECT operator than the embedded odcumentation - it is a simple type (single instance) and not a variable repeating group of nested data.
    Anyone had any success with these, or know of any collateral to assist in the process. Thanks.

    The process we are following is very simple. We are talking 10 columns from a source flat file table and wish to map this into a Varray/Nested table, with one column of Varchar2(10).
    When you create your map in OWB, select the construct object, you have to choose an object type - it does not allow you to select a VARAAY or NESTED table.
    I have then created an object defined in the same structure as the VARRAY/NESTED table - I have then made the VARRAY/NESTED table of this TYPE.
    Example:
    CREATE OR REPLACE TYPE "O_REL_PUB_INDEX" AS OBJECT (
    X_REL_PUB_INDEX_1 VARCHAR2(10))
    CREATE OR REPLACE TYPE "V_REL_PUB_INDEX" AS VARRAY(15) OF O_REL_PUB_INDEX
    In OWB you can then select O_REL_PUB_INDEX when creating the 'Contruct Object'.
    The problem I have is that when I map to my target column of type V_REL_PUB_INDEX and DEPLOY my map I get the following errors taken from OWB control centre
    Name
    Action
    Status
    Log
    TEST
    Create
    Warning
    ORA-06550: line 2931, column 9:
    PL/SQL: SQL Statement ignored
    TEST
    Create
    Warning
    ORA-06550: line 3174, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected OWB_USER.O_REL_PUB_INDEX got OWB_USER.V_REL_PUB_INDEX
    TEST
    Create
    Warning
    ORA-06550: line 401, column 7:
    PL/SQL: SQL Statement ignored
    TEST
    Create
    Warning
    ORA-06550: line 643, column 13:
    PL/SQL: ORA-00932: inconsistent datatypes: expected OWB_USER.O_REL_PUB_INDEX got OWB_USER.V_REL_PUB_INDEX
    TEST
    Create
    Warning
    ORA-06550: line 7221, column 9:
    PL/SQL: SQL Statement ignored
    TEST
    Create
    Warning
    ORA-06550: line 7464, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected OWB_USER.O_REL_PUB_INDEX got OWB_USER.V_REL_PUB_INDEX
    Any ideas? anyone succesfully mapped to either a VARRAY or an NESTED TABLE target column?

  • SQL ... varray / object types

    use 8i
    I have a problem with VARRAYS.
    With the following script there is an error when creating the VArray ->
    TypVa_STUDENT .
    "Type created with compilation errors" (Oracle SQLPlus)
    I can't explain why.
    Could it be that with the Type Typ_STUDENT the attribute COURSE already is a
    type
    which doesn't allow the VArray TypVa_STUDENT to be created
    B.B.
    Matthias
    create type Typ_COURSE as object
    MARK varchar2(200) ,
    SECTION varchar2(200) ,
    COURSENAME varchar2(200)
    create type TypVa_COURSE as
    varray(10) of Typ_COURSE ;
    create type Typ_STUDENT as object
    FNAME varchar2(200) ,
    LNAME varchar2(200) ,
    COURSE TypVa_COURSE
    create type TypVa_STUDENT as
    varray(10) of Typ_STUDENT ;
    create table tblREPORTCARD
    STUDENT TypVa_STUDENT
    null

    You can not include another varray in varray type. It will generate an error
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Matthias ([email protected]):
    use 8i
    I have a problem with VARRAYS.
    With the following script there is an error when creating the VArray ->
    TypVa_STUDENT .
    "Type created with compilation errors" (Oracle SQLPlus)
    I can't explain why.
    Could it be that with the Type Typ_STUDENT the attribute COURSE already is a
    type
    which doesn't allow the VArray TypVa_STUDENT to be created
    B.B.
    Matthias
    create type Typ_COURSE as object
    MARK varchar2(200) ,
    SECTION varchar2(200) ,
    COURSENAME varchar2(200)
    create type TypVa_COURSE as
    varray(10) of Typ_COURSE ;
    create type Typ_STUDENT as object
    FNAME varchar2(200) ,
    LNAME varchar2(200) ,
    COURSE TypVa_COURSE
    create type TypVa_STUDENT as
    varray(10) of Typ_STUDENT ;
    create table tblREPORTCARD
    STUDENT TypVa_STUDENT
    <HR></BLOCKQUOTE>
    null

  • Partitioned IOT of Object Type - mapping table not allowed for bitmap index

    Hi,
    looks like a feature available for standard Partitioned IOTs is not supported for object based tables, namely the MAPPING TABLE construct to support secondary local bitmap indexes.
    Can you confirm behaviour is as expected/documented?
    If so, is a fix/enhancement to support mapping table for object-based Partitioned IOTs in the pipeline?
    Results for partition-wise load using pipelined table function are very good, look-ups across tens of millions of rows are excellent.
    Environment = Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    OS = Oracle Enterprise Linux Server release 5.2 (Carthage) 2.6.18 92.el5 (32-bit)
    Here's the potted test-case...
    1) First the non object based Partitioned IOT - data is range-partitioned across the alphabet
    CREATE TABLE IOT_Table (
    textData VARCHAR2(10),
    numberData NUMBER(10,0),
    CONSTRAINT IOT_Table_PK PRIMARY KEY(textData))
    ORGANIZATION INDEX MAPPING TABLE PCTFREE 0 TABLESPACE Firewire
    PARTITION BY RANGE (textData)
    (PARTITION Text_Part_A VALUES LESS THAN ('B') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_B VALUES LESS THAN ('C') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_C VALUES LESS THAN ('D') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_D VALUES LESS THAN ('E') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_E VALUES LESS THAN ('F') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_F VALUES LESS THAN ('G') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_G VALUES LESS THAN ('H') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_H VALUES LESS THAN ('I') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_I VALUES LESS THAN ('J') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_J VALUES LESS THAN ('K') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_K VALUES LESS THAN ('L') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_L VALUES LESS THAN ('M') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_M VALUES LESS THAN ('N') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_N VALUES LESS THAN ('O') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_O VALUES LESS THAN ('P') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_P VALUES LESS THAN ('Q') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Q VALUES LESS THAN ('R') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_R VALUES LESS THAN ('S') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_S VALUES LESS THAN ('T') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_T VALUES LESS THAN ('U') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_U VALUES LESS THAN ('V') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_V VALUES LESS THAN ('W') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_W VALUES LESS THAN ('X') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_X VALUES LESS THAN ('Y') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Y VALUES LESS THAN ('Z') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Z VALUES LESS THAN (MAXVALUE) PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0))
    NOLOGGING PARALLEL -- FLASHBACK ARCHIVE IOT_Flashback_Data
    SQL> table IOT_TABLE created.
    2) Create the local secondary bitmap index utilising the underlying mapping table
    CREATE BITMAP INDEX IOT_Table_BMI1 ON IOT_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL;
    SQL> bitmap index IOT_TABLE_BMI1 created.
    3) Quick test to confirm all ok
    SQL> INSERT INTO IOT_Table VALUES ('ABC123',100);
    SQL> 1 rows inserted.
    SQL> SELECT * FROM IOT_Table;
    TEXTDATA NUMBERDATA
    ABC123     100
    4) Now create a minimal object type to use as the template for object table
    CREATE TYPE IOT_type AS OBJECT
    textData VARCHAR2(10 CHAR),
    numberData NUMBER(10,0)
    ) FINAL
    SQL> TYPE IOT_type compiled
    5) Attempt to create an object-based range partitioned IOT, including MAPPING TABLE clause as per step (1)
    CREATE TABLE IOTObj_Table OF IOT_type (textData PRIMARY KEY)
    OBJECT IDENTIFIER IS PRIMARY KEY ORGANIZATION INDEX
    MAPPING TABLE -- we'd like to use this feature to enable use of Bitmap Indexes...
    PCTFREE 0 TABLESPACE Firewire
    PARTITION BY RANGE (textData)
    (PARTITION Text_Part_A VALUES LESS THAN ('B') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_B VALUES LESS THAN ('C') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_C VALUES LESS THAN ('D') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_D VALUES LESS THAN ('E') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_E VALUES LESS THAN ('F') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_F VALUES LESS THAN ('G') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_G VALUES LESS THAN ('H') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_H VALUES LESS THAN ('I') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_I VALUES LESS THAN ('J') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_J VALUES LESS THAN ('K') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_K VALUES LESS THAN ('L') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_L VALUES LESS THAN ('M') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_M VALUES LESS THAN ('N') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_N VALUES LESS THAN ('O') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_O VALUES LESS THAN ('P') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_P VALUES LESS THAN ('Q') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Q VALUES LESS THAN ('R') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_R VALUES LESS THAN ('S') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_S VALUES LESS THAN ('T') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_T VALUES LESS THAN ('U') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_U VALUES LESS THAN ('V') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_V VALUES LESS THAN ('W') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_W VALUES LESS THAN ('X') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_X VALUES LESS THAN ('Y') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Y VALUES LESS THAN ('Z') PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0),
    PARTITION Text_Part_Z VALUES LESS THAN (MAXVALUE) PCTFREE 0 TABLESPACE Firewire Storage (Initial 10M Next 1M PCTIncrease 0))
    NOLOGGING PARALLEL -- FLASHBACK ARCHIVE IOT_Flashback_Data
    This errors out with the following...
    SQL Error: ORA-25182: feature not currently available for index-organized tables
    25182. 00000 - "feature not currently available for index-organized tables"
    *Cause:    An attempt was made to use one or more of the following feature(s) not
    currently supported for index-organized tables:
    CREATE TABLE with LOB/BFILE/VARRAY columns,
    partitioning/PARALLEL/CREATE TABLE AS SELECT options,
    ALTER TABLE with ADD/MODIFY column options, CREATE INDEX
    *Action:   Do not use the disallowed feature(s) in this release.
    6) Re-running the create table statement in step 5 without the MAPPING TABLE clause works fine. Not surprisingly an attempt to create a secondary local bitmap index on this table fails as there's no mapping table, like so...
    CREATE BITMAP INDEX IOTObj_Table_BMI1 ON IOTObj_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL;
    CREATE TABLE with LOB/BFILE/VARRAY columns,
    partitioning/PARALLEL/CREATE TABLE AS SELECT options,
    ALTER TABLE with ADD/MODIFY column options, CREATE INDEX
    *Action:   Do not use the disallowed feature(s) in this release.
    CREATE BITMAP INDEX IOTObj_Table_BMI1 ON IOTObj_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL
    Error at Command Line:99 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 - "invalid table name"
    7) Creating a secondary local b-tree index is fine, like so...
    SQL> CREATE INDEX IOTObj_Table_I1 ON IOTObj_Table (numberData)
    LOCAL STORAGE (INITIAL 1M PCTINCREASE 0 NEXT 512K) NOLOGGING PARALLEL;
    index IOTOBJ_TABLE_I1 created.
    8) A quick test to ensure object table ok...
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('DEF456',500));
    SQL> 1 rows inserted.
    SQL> SELECT * FROM IOTObj_Table;
    TEXTDATA NUMBERDATA
    DEF456     500

    Thanks Dan,
    the intention is to range partition based on the initial character, so A* -> Text_Part_A, B* -> Text_Part_B, and so on.
    Here's an example, using an empty IOTObj_Table as created previously.
    1) Set up & confirm some test data (two 'D's, one 'N', and two 'Z's)
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('DEF456',500));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('DDD111',510));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('N3000',515));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('ZZ1212',520));
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('Z111X',530));
    SQL> COMMIT;
    SQL> SELECT * FROM IOTObj_Table;
    TEXTDATA NUMBERDATA
    DDD111     510
    DEF456     500
    N3000     515
    Z111X     530
    ZZ1212     520
    2) Just to prove our IOT is enforcing the Primary Key based on the TextData attribute, try to insert a duplicate
    SQL> INSERT INTO IOTObj_Table VALUES (IOT_Type('Z111X',530));
    Error starting at line 141 in command:
    INSERT INTO IOTObj_Table VALUES (IOT_Type('Z111X',530))
    Error report:
    SQL Error: ORA-00001: unique constraint (OCDataSystems.SYS_IOT_TOP_84235) violated
    00001. 00000 - "unique constraint (%s.%s) violated"
    *Cause:    An UPDATE or INSERT statement attempted to insert a duplicate key.
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    *Action:   Either remove the unique restriction or do not insert the key.
    3) Now confirm that our data has been slotted into the range-based partition we expect using the PARTITION clause of SELECT...
    - The two 'D's...
    SQL> SELECT * FROM IOTObj_Table PARTITION (Text_Part_D);
    TEXTDATA NUMBERDATA
    DDD111     510
    DEF456     500
    - The single 'N'...
    SQL> SELECT * FROM IOTObj_Table PARTITION (Text_Part_N);
    TEXTDATA NUMBERDATA
    N3000     515
    - The two 'Z's...
    SQL> SELECT * FROM IOTObj_Table PARTITION (Text_Part_Z);
    TEXTDATA NUMBERDATA
    Z111X     530
    ZZ1212     520
    4) And to wrap up confirm an empty partition
    SELECT * FROM IOTObj_Table PARTITION (Text_Part_W);

  • How to pass an IN argument of object type from VB

    I need to call a PL/SQL function in Oracle 8.1.6 from VB. One of the IN arguments is an object type (TYPE). How would I instantiate the variable of Oracle object type on VB side so that it can be passed to the Oracle?
    Thank you

    Hi,
    Per the ODP docs,
    ODP.NET supports binding parameters of PL/SQL Associative Arrays which contain the following data types.
    +■ BINARY_DOUBLE+
    +■ BINARY_FLOAT+
    +■ CHAR+
    +■ DATE+
    +■ NCHAR+
    +■ NUMBER+
    +■ NVARCHAR2+
    +■ RAW+
    +■ ROWID+
    +■ UROWID+
    +■ VARCHAR2+
    It should work if you create a UDT to hold a varray of mdsys.sdo_geometry, for example.
    Hope it helps,
    Greg

  • Calling Stored Procedure(takes varray of objects as input) from jdeveloper

    How can i call Stored Procedure which takes varray of objects as input from jdeveloper
    My object is :
    TYPE Entry IS Object (
    Name VARCHAR2(1024),
    Value VARCHAR2(1024)
    & the varray is :
    TYPE EntryArr IS varray(10) OF Entry ;
    & the procedure is :
    PROCEDURE myProc( myEntryArr IN EntryArr )
    AS
    s varchar2(1024);
    BEGIN
    for i in 1.. myEntryArr .COUNT loop
    if myEntryArr(i).Name = 'Name1' then
    s := myEntryArr(i).Value
    end loop;
    end;

    hi 429071
    Maybe you can find some useful information in:
    "Oracle Database Java Developer's Guide"
    http://download-west.oracle.com/docs/cd/B14117_01/java.101/b12021.pdf
    see "6 Publishing Java Classes With Call Specs" > "Writing Object Type Call Specs"
    success
    Jan Vervecken

  • Help! JDBC & Oracle Object Type

    Hi all?
    I use JDBC to connect to ORACLE 8i DB...
    it has various kind of New Features of Oracle 8( eg. Oject Type
    like REF, Nested Tables, VArray... ).
    So I'd like to retrieve some Table consisted of general Column
    and REF, Varray, Nested Tables... I succeeded retrieving the
    data from general table with only general columns like number,
    varchar2 consulting Manuals... I use Custom Java Classes
    inheriting CustumDatum Interface...
    However, I cannot find any other solution to get data from
    Tables consisted of Object Features...
    So I'd like to know how to configure Custom Java Classes to map
    to Object Type like Varray, Ref...
    In manual, there's only way to get data from olny the column
    which is Object type, I mean i'd like to know how to get whole
    column's data using Custom Java Classes...
    It will be really thankful if you mail the answer or sample
    codes to me...
    Pls mail to [email protected]
    Thank you all,
    null

    Hi Eddy,
    Use sqlj tool, which generates java classes to
    corresponding object types in oracle 8i. Use these
    (or extend) classes to retrieve the data.
    bye
    MohanE
    Eddy Lim (guest) wrote:
    : Hi all?
    : I use JDBC to connect to ORACLE 8i DB...
    : it has various kind of New Features of Oracle 8( eg. Oject Type
    : like REF, Nested Tables, VArray... ).
    : So I'd like to retrieve some Table consisted of general Column
    : and REF, Varray, Nested Tables... I succeeded retrieving the
    : data from general table with only general columns like number,
    : varchar2 consulting Manuals... I use Custom Java Classes
    : inheriting CustumDatum Interface...
    : However, I cannot find any other solution to get data from
    : Tables consisted of Object Features...
    : So I'd like to know how to configure Custom Java Classes to map
    : to Object Type like Varray, Ref...
    : In manual, there's only way to get data from olny the column
    : which is Object type, I mean i'd like to know how to get whole
    : column's data using Custom Java Classes...
    : It will be really thankful if you mail the answer or sample
    : codes to me...
    : Pls mail to [email protected]
    : Thank you all,
    null

  • Varray of Objects: Initializing, Instantiation, Constructors, ORA-06531

         This is supposed to fill a varray with ten objects, calling methods in those objects and populating the objects from queries, then display fields from the objects via methods.  Error message is in comment at bottom.  Any ideas?
    -- Enable screen I/O
    SET SERVEROUTPUT ON SIZE 1000000
    SET VERIFY OFF
    -- object spec
      CREATE OR REPLACE TYPE employee4 AS OBJECT
      o_ename CHAR (20 char),
      o_empno NUMBER (4),
      o_sal NUMBER (10),
      o_thisno NUMBER (4),
      MEMBER FUNCTION get_o_ename RETURN CHAR, MEMBER PROCEDURE set_o_ename (o_thisno IN number),
      MEMBER FUNCTION get_o_empno RETURN NUMBER, MEMBER PROCEDURE set_o_empno (o_thisno IN number),
      MEMBER FUNCTION get_o_sal RETURN NUMBER, MEMBER PROCEDURE set_o_sal (o_thisno IN number),
      CONSTRUCTOR FUNCTION employee4 (o_ename CHAR,o_empno NUMBER,o_sal NUMBER,o_thisno NUMBER) RETURN SELF AS RESULT
    -- object body
      CREATE OR REPLACE TYPE BODY employee4 AS
      CONSTRUCTOR FUNCTION employee4 (o_ename IN CHAR,
      o_empno IN NUMBER,
      o_sal IN NUMBER,
      o_thisno IN NUMBER)
      RETURN SELF AS RESULT IS
      BEGIN
      SELF.o_ename := o_ename;
      SELF.o_empno := o_empno;
      SELF.o_sal := o_sal;
      SELF.o_thisno := o_thisno;
      RETURN;
      END;
      -- gets
      MEMBER FUNCTION get_o_ename RETURN CHAR IS
      BEGIN
      RETURN self.o_ename;
      END;
      MEMBER FUNCTION get_o_empno RETURN NUMBER IS
      BEGIN
      RETURN self.o_empno;
      END;
      MEMBER FUNCTION get_o_sal RETURN NUMBER IS
      BEGIN
      RETURN self.o_ename;
      END;
      -- sets
      MEMBER PROCEDURE set_o_ename(o_thisno IN number) IS
      BEGIN
      SELECT ename INTO SELF.o_ename FROM emp WHERE empno = SELF.o_thisno;
      END;
      MEMBER PROCEDURE set_o_empno(o_thisno IN number) IS
      BEGIN
      SELECT empno INTO SELF.o_empno FROM emp WHERE empno = SELF.o_thisno;
      END;
      MEMBER PROCEDURE set_o_sal(o_thisno IN number) IS
      BEGIN
      SELECT sal INTO SELF.o_sal FROM emp WHERE empno = SELF.o_thisno;
      END;
      END;
    DECLARE
      -- a varray of employees
      TYPE emp_varray1 IS VARRAY(10) OF employee4;
      varray_of_emps  EMP_VARRAY1;
      -- List of EMPNO's in order of appearance in EMP table (for cross-referencing, single-line retrieval)
      TYPE MYCREF_VARRAY IS VARRAY(10) OF NUMBER(4);
      varray_mycref MYCREF_VARRAY := MYCREF_VARRAY(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
      -- make a variable to store one empno
      thisno NUMBER(4);
      -- make a counter
      counter INT;
      -- query variables for the set calls
      q_ename CHAR(20 CHAR);
      q_empno NUMBER(4);
      q_sal NUMBER(10);
    BEGIN
      -- Put the first 10 EMPNO's in my cref array
      SELECT empno BULK COLLECT INTO varray_mycref FROM emp WHERE ROWNUM < 11;
      -- Use a loop to retrieve the first 10 objects in the "emp" table and put them in the varray of objects
      FOR counter IN 1..10 LOOP
      thisno := varray_mycref(counter);
      varray_of_emps(counter).set_o_ename(thisno);
      varray_of_emps(counter).set_o_empno(thisno);
      varray_of_emps(counter).set_o_sal(thisno);
      END LOOP;
      -- Use another loop to display the information in the reverse order.
      FOR counter in REVERSE 1..10 LOOP
      dbms_output.put_line((varray_of_emps(counter).get_o_ename()) || CHR(9) || (varray_of_emps(counter).get_o_empno()) || CHR(9) || (varray_of_emps(counter).get_o_sal()));
      END LOOP;
    END;
      This results in the following response in SQL*PLUS:
    Type created.
    Type body created.
    DECLARE
    ERROR at line 1:
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at line 33

    Hi,
    From metalink:
    Cause: An element or member function of a nested table or varray was
    referenced (where an initialized collection is needed) without the
    collection having been initialized.
    Action: Initialize the collection with an appropriate constructor or
    whole-object assignment.
    ORA 6531 Reference to uninitialized collection (Doc ID 48912.1)

  • Varray of Objects "Bind variable not declared" error.. I don't want a bind variable.

    Hello.
    This program is supposed to pull values from a table using a loop, and in the loop, put the values in objects in a varray.  I'm new to objects and am stumped trying to get this program to run.  When I attempt to run it in SQL*Plus  I get the following feedback:
    Type created.
    Type body created
    SP2-0552: Bind variable "MY_VARRAY_EMP1" not declared.
    I don't think I even need a bind variable.  Any feedback would be appreciated.  Here's the program:
    -- Enable screen I/O
    SET SERVEROUTPUT ON SIZE 1000000
    SET VERIFY OFF
    -- begin object spec
    CREATE OR REPLACE TYPE employee3 AS OBJECT
      ename CHAR (20 char),
      empno NUMBER (4),
      sal NUMBER (10),
      MEMBER FUNCTION get_ename RETURN CHAR, MEMBER PROCEDURE set_ename (SELF IN OUT NOCOPY employee3),
      MEMBER FUNCTION get_empno RETURN NUMBER, MEMBER PROCEDURE set_empno (SELF IN OUT NOCOPY employee3),
      MEMBER FUNCTION get_sal RETURN NUMBER, MEMBER PROCEDURE set_sal (SELF IN OUT NOCOPY employee3)
    -- begin object body
    CREATE OR REPLACE TYPE BODY employee3 AS
      -- gets
      MEMBER FUNCTION get_ename RETURN CHAR IS
      BEGIN
      RETURN self.ename;
      END;
      MEMBER FUNCTION get_empno RETURN NUMBER IS
      BEGIN
      RETURN self.empno;
      END;
      MEMBER FUNCTION get_sal RETURN NUMBER IS
      BEGIN
      RETURN self.ename;
      END;
      -- sets
      MEMBER PROCEDURE set_ename(SELF IN OUT employee3) IS
      BEGIN
      self.ename := ename;
      END;
      MEMBER PROCEDURE set_empno(SELF IN OUT employee3) IS
      BEGIN
      self.empno := empno;
      END;
      MEMBER PROCEDURE set_sal(SELF IN OUT employee3) IS
      BEGIN
      self.sal := sal;
      END;
    END;
    DECLARE
      TYPE emp_varray IS VARRAY(10) OF EMPLOYEE3;
      my_varray_emp1 EMP_VARRAY;
      -- List of EMPNO's in order of appearance in EMP table (for cross-referencing, single-line retrieval)
      TYPE MYCREF_VARRAY IS VARRAY(10) OF NUMBER(4);
      varray_mycref MYCREF_VARRAY := MYCREF_VARRAY(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
      this_object EMPLOYEE3;
      -- make a variable to store one empno
      thisno NUMBER(4);
      -- make a counter
      counter INT;
      -- query variables for the set calls
      q_ename CHAR(20 CHAR);
      q_empno NUMBER(4);
      q_sal NUMBER(10);
      my_result INT;
    BEGIN
      --my_varray_emp1 := EMP_VARRAY(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
      -- Put the first 10 EMPNO's in my cref array
      SELECT empno BULK COLLECT INTO varray_mycref FROM emp WHERE ROWNUM < 11;
      -- Use a loop to retrieve the first 10 objects in the "emp" table and put them in the varray of objects
      q_ename := NULL;
      q_empno := NULL;
      q_sal := NULL;
      my_result := NULL;
      this_object := NULL;
      counter := 1;
      FOR counter IN 1..10 LOOP
      thisno := varray_mycref(counter);
      this_object := my_varray_emp1(counter);
      SELECT ename INTO q_ename FROM emp WHERE empno = thisno;
      my_result := this_object.set_ename(q_ename, NULL);
      SELECT empno INTO q_empno FROM emp WHERE empno = thisno;
      my_result := this_object.set_empno(q_empno, NULL);
      SELECT sal INTO q_sal FROM emp WHERE empno = thisno;
      my_result := this_object.set_sal(q_sal, NULL);
      END LOOP;
      -- Use another loop to display the information in the reverse order.
      FOR counter in REVERSE 1..10 LOOP
      this_object =: my_varray_emp1(counter);
      dbms_output.put_line((this_object.get_ename()) || CHR(9) || (this_object.get_empno()) || CHR(9) || (this_object.get_sal()));
      END LOOP;
    END;

    Cleaning up your code for errors and eliminating unnecessary complexity...
    Add a user-defined constructor which takes all attributes and calls the "setter" procedures in one trip:
    -- Enable screen I/O
    set SERVEROUTPUT on size 1000000
    set VERIFY off
    -- begin object spec
    create or replace type employee3 as object
      ename CHAR (20 char),
      empno NUMBER (4),
      sal NUMBER (10),
    constructor function employee3(
        self    in out nocopy    employee3,
        aEname    in        char,
        aEmpNo    in        integer,
        aSal    in        number
      return self as result,
      member function get_ename return CHAR, member procedure set_ename (SELF in out nocopy employee3, ename in char),
      member function get_empno return NUMBER, member procedure set_empno (SELF in out nocopy employee3, empno in integer),
      member function get_sal return NUMBER, member procedure set_sal (SELF in out nocopy employee3, sal in integer)
    -- begin object body
    create or replace type body employee3 as
      constructor function employee3(
        self    in out nocopy    employee3,
        aEname    in        char,
        aEmpNo    in        integer,
        aSal    in        number
      return self as result
      is
      begin
        self.set_ename(aEname);
        self.set_empno(aEmpNo);
        self.set_sal(aSal);
        return;
      end;
      -- gets
      member function get_ename return CHAR is
      begin
      return self.ename;
      end;
      member function get_empno return NUMBER is
      begin
      return self.empno;
      end;
      member function get_sal return NUMBER is
      begin
      return self.sal;
      end;
      -- sets
      member procedure set_ename(SELF in out employee3, ename in char) is
      begin
      self.ename := ename;
      end;
      member procedure set_empno(SELF in out employee3, empno in integer) is
      begin
      self.empno := empno;
      end;
      member procedure set_sal(SELF in out employee3, sal in integer) is
      begin
      self.sal := sal;
      end;
    end;
    (Since I don't have EMP handy at the moment, create a simple view instead)
    create or replace view emp
    as
    select    'EMP' || to_char(level) ename
    ,    level + 100 empno
    ,    DBMS_RANDOM.VALUE(25000,75000) sal
    from    DUAL
    connect by
        level <= 20
    Get rid of your loop and individual SELECTs, and replace it with a single SELECT BULK COLLECT INTO...
    declare
      type emp_varray is varray(10) of EMPLOYEE3;
      my_varray_emp1 EMP_VARRAY;
      this_object EMPLOYEE3;
    begin
      -- No need for a loop. Use SELECT BULK COLLECT INTO, together with a user-defined constructor call (since the
      -- user-defined constructor overrides the default constructor we need to call it using named-parameter notation):
      select    new employee3(
                aEname    => e.ename,
                aEmpNo    => e.empno,
                aSal    => e.sal
      bulk collect into
            my_varray_emp1
      from        emp e
      where        rownum <= 10;
      -- Use another loop to display the information in the reverse order.
      for counter in reverse 1..10 loop
      this_object := my_varray_emp1(counter);
      dbms_output.put_line((this_object.get_ename()) || chr(9) || to_char(this_object.get_empno()) || chr(9) || to_char(this_object.get_sal()));
      end loop;
    end;
    EMP10        
    110    60110
    EMP9         
    109    67485
    EMP8         
    108    58242
    EMP7         
    107    47597
    EMP6         
    106    58995
    EMP5         
    105    49098
    EMP4         
    104    47406
    EMP3         
    103    67574
    EMP2         
    102    59663
    EMP1         
    101    52929
    PL/SQL procedure successfully completed.
    Gerard

Maybe you are looking for

  • Case in-sensitive search

    Is it possible to configure the database to perform all searches as case in-sensitve. Ex. select * from MyTable where MyField = 'Question'; should also return rows from MyTable where Myfield contains 'question', 'QUESTION' etc. null

  • Authorizations missing for aggregation (":")

    Hi ALL, i have already included these in my authorization object Y_WBS_D174.........for 0WBS_ELEMT__0RESP_CCTR I     EQ     C174000 I     EQ     D174000 I     EQ     N174000 I     EQ     R174000   Authorizations missing for aggregation (":")   Charac

  • Changing worksheet names in excel 2010

    I recently switched from excel 2003 to 2010 usnig Oralce BI Add In In 2003 I could change the names of the Worksheets and it would not cause an issue with the Oracle BI queries In Excel 2010 if I change the name of a worksheet after I have created a

  • Aperture with iMac G5

    I use a non-iSight 2 gHz iMac G5 (non-Intel) with 2 gB of RAM. It has the ATI (0x1002) display card and Aperture Compatibilty Checker says it's OK for Aperture. Most of the ads Apple runs for Aperture seem to show big Cinema Displays, which means the

  • LMS4.0.1 Nexus 5020 - internal error in inventory collection

    Hello, 2 Nexus 5020 (SysObjId ...3.719) brings internal error in inventory collection as following: "RICS0001: Internal Error, unable to process the collected data from the device" whereby 2 other devices from same type, same sysobjid are working wel