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

Similar Messages

  • 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.

  • Oracle Object Types and XML

    Hi All
    I have oracle object types created.
    <code>
    CREATE OR REPLACE
    TYPE CONFIRM_APP_CONFIRM_ENQUIRY_AT AS OBJECT
    ENQATTRIBTYPECODE VARCHAR2(1000),
    ENQATTRIBVALUECODE VARCHAR2(1000),
    ENQATTRIBSTRINGVALUE VARCHAR2(1000),
    ENQATTRIBNUMVALUE NUMBER,
    ENQATTRIBDATEVALUE DATE
    </code>
    I m using this type for couple of columns in a table
    and then i try to use this procedure which generates XML
    <code>
    BEGIN
    MY_SQL :=
    DBMS_XMLQUERY.NEWCONTEXT
    ( 'Select Nvl(Enquiry_Number,9999) "EnquiryNumber",
    External_System_Reference "ExternalSystemReference",
    External_System_Number "ExternalSystemNumber",
    Service_Code "ServiceCode",
    Subject_Code "SubjectCode",
    Enquiry_Description "EnquiryDescription",
    Enquiry_Location "EnquiryLocation",
    Enquiry_Status_Code "EnquiryStatusCode",
    Assigned_Office_Code "AssignedOfficerCode",
    Logged_Time "LoggedTime",
    EnquiryX "EnquiryX",
    EnquiryY "EnquiryY",
    Site_Code "SiteCode",
    Central_Asset_Id "CentralAssetId",
    Contact_Name "ContactName",
    Contact_Phone "ContactPhone",
    Contact_Fax "ContactFax",
    Contact_Email "ContactEmail",
    Enquiry_Reference "EnquiryReference",
    Enquiry_Class_Code "EnquiryClassCode",
    Notice_From_Org_Code "NoticeFromOrgCode",
    Works_Reference "WorksReference",
    Job_Number "JobNumber",
    Address_Reference "AddressReference",
    enquiry_attribute1 "EnquiryAttribute",
    enquiry_attribute2 "EnquiryAttribute",
    enquiry_attribute3 "EnquiryAttribute",
    enquiry_attribute4 "EnquiryAttribute",
    enquiry_attribute5 "EnquiryAttribute",
    enquiry_attribute6 "EnquiryAttribute",
    enquiry_attribute7 "EnquiryAttribute",
    enquiry_attribute8 "EnquiryAttribute",
    enquiry_attribute9 "EnquiryAttribute",
    enquiry_attribute10 "EnquiryAttribute",
    enquiry_attribute11 "EnquiryAttribute",
    enquiry_attribute12 "EnquiryAttribute",
    enquiry_attribute13 "EnquiryAttribute",
    enquiry_attribute14 "EnquiryAttribute",
    enquiry_attribute15 "EnquiryAttribute",
    enquiry_attribute16 "EnquiryAttribute",
    enquiry_attribute17 "EnquiryAttribute",
    enquiry_attribute18 "EnquiryAttribute",
    enquiry_attribute19 "EnquiryAttribute",
    enquiry_attribute20 "EnquiryAttribute",
    enquiry_customer "EnquiryCustomer",
    enquiry_document "DocumentLink"
    FROM XXHCC_HOLDING_CONFIRM WHERE
    EXTERNAL_SYSTEM_REFERENCE ='
    || EXTERNAL_SYSTEM_REFERENCE
    || '
    AND message_status = ''FAIL'''
    DBMS_XMLQUERY.SETROWSETTAG (MY_SQL, 'Operation');
    DBMS_XMLQUERY.SETROWTAG (MY_SQL, 'NewEnquiry');
    L_XML := DBMS_XMLQUERY.GETXML (MY_SQL);
    DBMS_XMLQUERY.CLOSECONTEXT (MY_SQL);
    </code>
    when i get the xml as output, i get this..
    <code>
    <Operation>
    <NewEnquiry num="1">
    <EnquiryNumber>9999</EnquiryNumber>
    <ExternalSystemReference>4343017</ExternalSystemReference>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ServiceCode>HWAY</ServiceCode>
    <SubjectCode>MAIN</SubjectCode>
    <EnquiryDescription>TAI-Highway Maintenance</EnquiryDescription>
    <EnquiryLocation>O/S Cheese Pub</EnquiryLocation>
    <LoggedTime>2008-04-09T08:33:36</LoggedTime>
    <SiteCode>19101890</SiteCode>
    <ContactName>MRS xyz</ContactName>
    <ContactPhone>3434343</ContactPhone>
    <EnquiryReference>CRMHUB</EnquiryReference>
    <NoticeFromOrgCode>ABC</NoticeFromOrgCode>
    <WorksReference>4343017</WorksReference>
    <EnquiryAttribute>
    <ENQATTRIBTYPECODE>CSPL</ENQATTRIBTYPECODE> <ENQATTRIBSTRINGVALUE>n.a</ENQATTRIBSTRINGVALUE>
    </EnquiryAttribute>
    <EnquiryAttribute>
    <ENQATTRIBTYPECODE>CSAI</ENQATTRIBTYPECODE>
    <ENQATTRIBSTRINGVALUE>Cracked Path-Loose Flagstone</ENQATTRIBSTRINGVALUE>
    </EnquiryAttribute>
    <EnquiryAttribute> <ENQATTRIBTYPECODE>CSDL</ENQATTRIBTYPECODE> <ENQATTRIBSTRINGVALUE>No</ENQATTRIBSTRINGVALUE>
    </EnquiryAttribute>
    <EnquiryAttribute>
    <ENQATTRIBTYPECODE>CSIM</ENQATTRIBTYPECODE>
    </EnquiryAttribute>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <EnquiryAttribute/>
    <ENQUIRY_CUSTOMER>
    <CUSTOMER_ALT_PHONE>00</CUSTOMER_ALT_PHONE>
    <CUSTOMER_PRIMARY_ADDRESS>,,0, ABC Street</CUSTOMER_PRIMARY_ADDRESS>
    <CUSTOMER_TOWN_NAME>UK</CUSTOMER_TOWN_NAME>
    <CUSTOMER_COUNTY_NAME>UK</CUSTOMER_COUNTY_NAME>
    <CUSTOMER_POST_CODE>AB1 3QT</CUSTOMER_POST_CODE>
    </ENQUIRY_CUSTOMER>
    </NewEnquiry>
    </Operation>
    </code>
    My question is i m transferring this XML to a third party webservice and it does inserting into a third party application.
    The problem is if you look under EnquiryAttribute tag ENQATTRIBSTRINGVALUE and ENQATTRIBTYPECODE i need this to be in lowercase.
    As the xml is getting automatically generated how do i achieve this. I feel them in the uppercase is causing problems at the other end.
    Any help appreciated
    Srini
    Message was edited by:
    sikhasrinivas

    Use "..." delimiters in the CREATE TYPE (and in all your code that references the type).

  • Domains for Oracle object types

    When I create a domain for a certain Oracle object type there is no way to create some kind of inheritance tree (and there is no discriminator support it seems). On the database level I have several object types that extend a certain base object type. I want to do the same at the BC4J level. But unfortunately this doesn't seem possible. Is there a work-around for it? I don't mind to write a little extra code, any hints or help are appreciated.
    Regards,
    Peter
    P.S.
    It seems the object type / domain support in JDeveloper 9.0.3(.1) isn't quite up there with entities and view objects. It's not even possible to change an attribute name at the Java side using the domain dialog (it's only possible by manually editing the XML and Java files). Will JDeveloper 9.0.4 have broader support for object types / domains?

    I've found a way to implement the inheritance myself, at least a start. I've noticed all custom domains for oracle object types have the static method "getCustomerDatumFactory". In this method (in the base domain class) normally an instance of the base type is returned. I've modified this method so that it returns instances of the different subtypes depending on the value of a certain column. To make this work I first have to edit the Java files of the subtypes and let them extend the base type instead of the Struct class. The factory method looks like this:
    public static CustomDatumFactory getCustomDatumFactory()
        if (fac == null)
          class facClass implements CustomDatumFactory
            public CustomDatum create(Datum d, int sql_type_code) throws SQLException
              if (d != null)
                BaseType b = new BaseType(d);
                if ("subtype1".equals(b.getType())) b = new SubType1(d);
                else if ("subtype2".equals(p.getType())) b = new SubType2(d);
                else System.err.println("Unknown subtype: " + b.getType());
                return b;
              return null;
          fac = new facClass();
        return fac;
      }I also tried to save several of the subtypes in the database in the attribute field (which is of the base type) using setAttribute, this seems to work out-of-the-box. It seems for now I only get this to work if the object type is saved in a column of a certain table, I can't get it to work (yet) for object type tables (see the other recent topic of mine).
    Is this the correct way to implement what I want? Or is there a better way?
    Regards,
    Peter

  • Problem using Oracle Object Types and Arrays.

    I'm currently trying to work with oracle object types in java and I'm running into some issues when trying to add an item to an array.
    The basic idea is that I have a header object and a detail object (both only containing an ID and a description). Inside of my java code I'm trying to add a new detail line to the header that has been retrieved from the database.
    Here's what I'm working with.
    --Oracle Objects:
    CREATE OR REPLACE TYPE dtl_obj AS OBJECT
        detail_id INTEGER,
        header_id INTEGER,
        detail_desc VARCHAR2(300)
    CREATE TYPE dtl_tab AS TABLE OF dtl_obj;
    CREATE OR REPLACE TYPE hdr_obj AS OBJECT
        header_id INTEGER,
        src VARCHAR(30),
        details dtl_tab
    CREATE TYPE hdr_tab AS TABLE OF hdr_obj;
    /--Java test methods
         public static void main(String[] args) throws SQLException,
                   ClassNotFoundException
              // Initialize the objects
              Test t = new Test();
              t.connect(); //Connects to the database
              //The oracle connection will be accessible through t.conn
              // Create the oracle call
              String query = "{? = call get_header(?)}";
              OracleCallableStatement cs = (OracleCallableStatement) t.conn.prepareCall(query);
              cs.registerOutParameter(1, OracleTypes.ARRAY, "HDR_TAB"); //Register the out parameter and associate it with our oracle type
              int[] hdrs = { 240 }; //we just want one for testing.
              ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(
                        "ARRAY_T", t.conn);
              oracle.sql.ARRAY oHdrs = new ARRAY(descriptor, t.conn, hdrs);
              cs.setARRAY(2, oHdrs); //Set the headers to retrieve
              // Execute the query
              cs.executeQuery();
              try
                   ARRAY invArray = cs.getARRAY(1);
                   // Start the retrieval process
                   Class cls = Class.forName(Header.class.getName());
                   Map<String, Class<?>> map = t.conn.getTypeMap();
                   map.put(Header._SQL_NAME, cls);
                   Object[] invoices = (Object[]) invArray.getArray();
                   ArrayList<Header> invs = new ArrayList(
                             java.util.Arrays.asList(invoices));
                   if (invs != null)
                        for (Header inv : invs)
                             System.out.println(inv.getHeaderId() + " " + inv.getSrc());
                             t.addDetail(inv, "new line");
                             for (Detail dtl : inv.getDetails().getArray()) // Exception thrown here
    //                              java.sql.SQLException: Fail to construct descriptor: Invalid arguments
    //                              at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    //                              at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
    //                              at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:861)
    //                              at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:128)
    //                              at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:109)
    //                              at com.pcr.tst.Detail.toDatum(Detail.java:40)
    //                              at oracle.jpub.runtime.Util._convertToOracle(Util.java:151)
    //                              at oracle.jpub.runtime.Util.convertToOracle(Util.java:138)
    //                              at oracle.jpub.runtime.MutableArray.getDatumElement(MutableArray.java:1102)
    //                              at oracle.jpub.runtime.MutableArray.getOracleArray(MutableArray.java:550)
    //                              at oracle.jpub.runtime.MutableArray.getObjectArray(MutableArray.java:689)
    //                              at oracle.jpub.runtime.MutableArray.getObjectArray(MutableArray.java:695)
    //                              at com.pcr.tst.DetailTable.getArray(DetailTable.java:76)
    //                              at com.pcr.tst.Test.main(Test.java:91)
                                  System.out.println(dtl.getDetailDesc());
              catch (Exception ex)
                   System.out.println("Error while retreiving header");
                   ex.printStackTrace();
              public void addDetail(Header hdr, String desc) throws Exception
              if (hdr == null)
                   throw new Exception("header not initialized");
              // Convert the current list to an ArrayList so we can easily add to it.
              ArrayList<Detail> dtlLst = new ArrayList<Detail>();
              dtlLst.addAll(java.util.Arrays.asList(hdr.getDetails().getArray()));
              // Create the new detail
              Detail dtl = new Detail();
              dtl.setDetailDesc(desc);
              // add the new detail
              dtlLst.add(dtl);
              Detail[] ies = new Detail[dtlLst.size()];
              ies = dtlLst.toArray(new Detail[0]);
              DetailTable iet = new DetailTable(ies);
              hdr.setDetails(iet);
         }I know its the addDetail method causing the issue because if I comment out the t.addDetail(inv, "new line"); call it works fine.
    Message was edited by:
    pcristini

    Oracle® Database Object-Relational Developer's Guide
    Also note that object relational database design is often less performant and scalable than relational. It is not very often used in production environments.
    However, the object orientated programming feature that is provided with Oracle object feature set are used and can make development and interfaces a lot easier.
    So in a nutshell. Say no to ref and nested table columns. Say yes to most of the other object features. IMO of course...

  • Debugging Oracle Object types

    Hi
    I'm trying to debug a application (in 9i Release 2) using PL/SQL object types and was wondering if JDev can help.
    I can see the objects, and their code, but the debugger seems unable to step into them, see local variables etc. It also incorrectly identifies code errors -- in short it appears to be using the 9i Release 1 drivers.
    I've just installed version 9.0.3.2 but that hasn't helped. The release notes say helpfully that 9.0.3 can handle the drivers for 9i R2, but it won't use them!
    I'm about to try the 10g preview, but I'm not feeling hopeful. Is this something I can expect to be fixed or do I have to find some other way of debugging my code?
    Thanks,
    Glenn.

    Hi,
    I also have problems debugging oracle objects. I'm running an Oracle Database Version 9.2.0.1.0 and use
    JDeveloper 9.0.3 to remotely debug PL/SQL Code. The debugging works fine when I'm setting breakpoints and
    step through the code.
    But I seem to be unable to list the value of variables of
    object types and variables of nested table types. And of course I cannot set conditional breakpoints on variables that have an Oracle object type. If I try 10g, there is no improvement. The object types are not recognized as Oracle object types or nested table types, instead they are shown as $Oracle.builtin.OPAQUE
    I need this feature to remotely debug procedures, that mostly use Oracle object types as parameters. Is there any possibility that I can get this feature to work? Otherwise JDeveloper is not much of a use for me when I'm debugging PL/SQL code.
    Thanks,
    Astrid
    I provided an example, in which I create the above mentioned types and fill them with data, but where I'm unable to retrieve the values of the variables in JDeveloper:
    ---------------------EXAMPLE--------------------------
    PROMPT Creating TYPE 'ot_hwemployee'
    CREATE OR REPLACE TYPE ot_hwemployee AS OBJECT (
    emp_id NUMBER (10),
    emp_name VARCHAR2 (200)
    PROMPT Creating TYPE 'nt_hwemployee'
    CREATE OR REPLACE TYPE nt_hwemployee AS TABLE OF ot_hwemployee
    PROMPT Creating TYPE 'nt_hwinteger'
    CREATE OR REPLACE TYPE nt_hwinteger AS TABLE OF NUMBER (20)
    PROMPT Creating PROCEDURE 'checkEmployees'
    CREATE OR REPLACE PROCEDURE checkEmployees
    AS
    vnt_employees nt_hwemployee;
    BEGIN
    vnt_employees := nt_hwemployee(ot_hwemployee(1, 'Mustermann Max'),
    ot_hwemployee(2, 'Beispiel Barbara'),
    ot_hwemployee(3, 'Schober-Gant Astrid'));
    deleteemployees(vnt_employees);
    END checkEmployees;
    PROMPT Creating PROCEDURE 'deleteEmployees'
    CREATE OR REPLACE PROCEDURE deleteEmployees (
    pnt_employees IN OUT nt_hwemployee)
    AS
    vnt_employees_deleted nt_hwinteger;
    BEGIN
    vnt_employees_deleted := nt_hwinteger();
    FOR i IN pnt_employees.FIRST .. pnt_employees.LAST LOOP
    IF (pnt_employees(i).emp_id > 2) THEN
    vnt_employees_deleted.EXTEND;
    vnt_employees_deleted(vnt_employees_deleted.COUNT) := pnt_employees(i).emp_id;
    pnt_employees.delete(i);
    END IF;
    END LOOP;
    END deleteEmployees;
    -------------------------END EXAMPLE-------------------

  • How to return Values from Oracle Object Type to Java Class Object

    Hello,
    i have created an Oracle Object Types in the Database. Then i created Java classes with "jpub" of these types. Here is an example of the type.
    CREATE OR REPLACE TYPE person_type AS OBJECT
    ID NUMBER,
    vorname VARCHAR2(30),
    nachname VARCHAR2(30),
    geburtstag DATE,
    CONSTRUCTOR FUNCTION person_type RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_id NUMBER) RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_vorname VARCHAR2,
    p_nachname VARCHAR2,
    p_geburtstag DATE) RETURN SELF AS RESULT,
    MEMBER FUNCTION object_exists(p_id NUMBER) RETURN BOOLEAN,
    MEMBER PROCEDURE load_object(p_id NUMBER),
    MEMBER PROCEDURE save_object,
    MEMBER PROCEDURE insert_object,
    MEMBER PROCEDURE update_object,
    MEMBER PROCEDURE delete_object
    MEMBER PROCEDURE load_object(p_id NUMBER) IS
    BEGIN
    SELECT p.id, p.vorname, p.nachname, p.geburtstag
    INTO SELF.ID, SELF.vorname, self.nachname, SELF.geburtstag
    FROM person p
    WHERE p.id = p_id;
    END;
    My problem is, that if i use the member function "load_object" from my java app it doesnt return the selected values to the java class and i dont know why. I use the java class like this:
    PersonObjectType p = new PersonObjectType();
    p.load_object(4);
    There is a reocrd in the database with id = 4 and the function will execute successful. But if i try to use "p.getVorname()" i always get "NULL". Can someone tell me how to do that?
    Thanks a lot.
    Edited by: NTbc on 13.07.2010 15:36
    Edited by: NTbc on 13.07.2010 15:36

    CallableStatement =
    "DECLARE
    a person_type;
    BEGIN
    a.load_object(4);
    ? := a;
    END;"
    And register as an out parameter.
    Edited by: michael76 on 14.07.2010 05:01

  • Working with oracle object type tables

    Hi,
    I've created a table which only contains Oracle object types (e.g. CREATE TABLE x OF <...>). When I create an Entity for this table using the Entity wizard, I end up with an entity with the attributes of the base object type and two special attributes REF$ (reference to the object type instance) and SYS_NC_OID$ (unique object identifier). The REF$ attribute is on the Java side of type oracle.jbo.domain.Ref and the other attribute is on the Java side a simple String.
    It seems this only allows me to save objects of the base type in this table. First of all in my situation this is also impossible because the base type is not instantiable. What I do want is to save several different subtypes into this table using the BC4J custom domain mechanism. Is there any way to make this possible? I first thought I could maybe do something with the special REF$ attribute, but this doesn't seem te case. So I might need to override most of the EntityImpl methods, like doUML, remove etc. Am I right? And does anyone have any hints on how to do this?
    Regards,
    Peter

    Peter:
    Hi,
    I've created a table which only contains Oracle
    object types (e.g. CREATE TABLE x OF <...>).
    When I create an Entity for this table using the
    Entity wizard, I end up with an entity with the
    attributes of the base object type and two special
    attributes REF$ (reference to the object type
    instance) and SYS_NC_OID$ (unique object identifier).
    The REF$ attribute is on the Java side of type
    oracle.jbo.domain.Ref and the other attribute is on
    the Java side a simple String.
    It seems this only allows me to save objects of the
    base type in this table. First of all in my situation
    this is also impossible because the base type is not
    instantiable. What I do want is to save several
    different subtypes into this table using the BC4J
    custom domain mechanism. Is there any way to make
    this possible? Sorry, but this is not supported out of the box.
    Since you have an object table, you wouldn't use domains to achieve this. Instead, you would have a superclass and subclass entity objects, e.g., PersonEO subclassed into StudentEO and EmployeeEO.
    I first thought I could maybe do
    something with the special REF$ attribute, but this
    doesn't seem te case. So I might need to override
    most of the EntityImpl methods, like doUML, remove
    etc. Am I right? And does anyone have any hints on
    how to do this?
    If you want, you can try this by overridding EntityImpl's:
       protected StringBuffer buildDMLStatement(int operation,
          AttributeDefImpl[] allAttrs,
          AttributeDefImpl[] retCols,
          AttributeDefImpl[] retKeys,
          boolean batchMode)
    and
       protected int bindDMLStatement(int operation,
          PreparedStatement stmt,
          AttributeDefImpl[] allAttrs,
          AttributeDefImpl[] retCols,
          AttributeDefImpl[] retKeys,
          HashMap retrList,
          boolean batchMode) throws SQLException
    Handle the case when operation == DML_INSERT.
    There, build an insert statement with substitutable row, e.g.:
    INSERT INTO persons VALUES (person_t('Bob', 1234));
    INSERT INTO persons VALUES (employee_t('Joe', 32456, 12, 100000));
    where person_t and employee_t are database types and you are invoking the respective constructor.
    Thanks.
    Sung

  • ERD and oracle object types

    Is there a good way to model oracle object types using ERD's in designer 6i. I can only figure out how to map to tables with columns of predefined datatypes (varchar2, number, date, long). I'd like to use designer to create new datatypes. Is this possible? Thanks.

    Hi Wiiliam
    Sorry for the late acknowledgement (i dozed off!).. Thanks for the response. So the private instance specific to a session ensure that theres no conflict between multiple requests to the same stored proc and hence no conflict of data... Great
    Chaitanya

  • How to user jdbc visit oracle object type function?

    1、create oracle object
    create type cocotestparam1 as object
    (id number,
    name varchar(10)
    2、add function to object
    alter type cocotestparam1 add member function test1(t number) return member;
    3、create object body
    create type body cocotestparam1 as
    memeber function test1(t number)
    return number
    is
    begin
    return t;
    end;
    end;
    how can I visit the object cocotestparam1's function?
    and how can I user jdbc visit the function?

    CallableStatement =
    "DECLARE
    a person_type;
    BEGIN
    a.load_object(4);
    ? := a;
    END;"
    And register as an out parameter.
    Edited by: michael76 on 14.07.2010 05:01

  • Require help on Array of Nested tables and Oracle Object type

    Hi All,
    I have a scenario where I have some millions of records received from a flat file and the record is stored in Table as below:
    Tablename: FILE_RECORD
    Rows:
    FILE_REG_ID = 1
    RECORD_NBR = 1     
    PROCESSED_IND = U
    RECORD= 00120130326006A
    FILE_REG_ID = 1
    RECORD_NBR = 2     
    PROCESSED_IND = U
    RECORD= 00120130326003
    1) I have to read these records at once and
    a) Split the RECORD column to get various other data Eg: Fld1=001, Fld2=20130326, Fld3 = 003
    b) send as an Array to Java.
    2) Java will format this into XML and sent to other application.
    3) The other application returns a response as Successful or Failure to Java in XML
    4) Java will send RECORD_NBR and the corresponding response as Success or Failure back to PLSQL
    5) PLSQL should match the RECORD_NBR and update the PROCESSED_IND = P.
    I 'm able to achieve this using SQL Table type by creating a TYPE for Each of the fields (Flds) however the problem is Java cannot Access the parameters as the TYPE are of COLUMN Types
    Eg: For RECORD_NBR
    SUBTYPE t_record_nbr IS FILE_RECORD.T010_RECORD_NBR%TYPE;
    Can you please let me know how I can achieve this to support Java, I know one way that is by creating an OBJECT TYPE and a TABLE of the OBJECT TYPE.
    Eg: T_FILE_RECORD_REC IS OBJECT
    FILE_REG_ID number(8), RECORD_NBR number (10), PROCESSED_IND varchar2(1), RECORD varchar(20)
    Create type T_FILE_RECORD_TAB IS TABLE OF T_FILE_RECORD_REC
    However I'm facing a problem to populate an Array of records, I know I'm missing something important. Hence please help.
    It would be helpful to provide some guidelines and suggestions or Pseudo or a Code to achieve this. Rest all I can take up further.
    Thanks in advance,

    I know once way that is creating a OBJECT TYPE and a TABLE of OBJECT TYPE, howeve I feel I'm missing something to achieve this.You're right, you need SQL object types created at the database level. Java doesn't know about locally defined PL/SQL types
    However you can do without all this by creating the XML directly in PL/SQL (steps 1+2) and passing the document to Java as XMLType or CLOB.
    Are you processing the records one at a time?

  • 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

  • DatabaseMetaData for Oracle Object Types

    I have successfully written a Java program to read a schema - i.e. Tables, Primary Keys, Imported Keys, Exported Keys & Columns - using DatabaseMetaData. However, I need to decompose Oracle Objects.
    My test case is:
    SQL> desc object_column_table
    Name Null? Type
    ID NUMBER(11)
    TYP OBJ_COL_TYP
    SQL> desc obj_col_typ
    Name Null? Type
    VC VARCHAR2(255)
    NUM NUMBER(11)
    DT DATE
    CH CHAR(7)
    I believe I have found the method that I require:
    public void showAttributes(String schema, String typeName, String attribute)
    The JavaDoc says "Retrieves a description of the given attribute of the given type for a user-defined type (UDT) that is available in the given schema and catalog."
    However, this throws "java.sql.SQLException: Unsupported feature"
    My driver details are:
    Driver Name: Oracle JDBC driver
    Version: 10.1.0.2.0
    Major Version: 10
    Minor Version: 1
    JDBC Major Version: 10
    JDBC Minor Version: 1
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
    With the Partitioning, OLAP and Data Mining options
    So, how do I decompose Oracle Objects?
    Thanks in advance for your help.

    reynaudj,
    Try searching this forum's archives for the term "STRUCT". Perhaps also search the OTN Web site as well.
    Good Luck,
    Avi.

  • Oracle Object Type Constructor Called Multiple Times

    I have an object type with a custom constructor. In SQL, when I reference the attributes the constructor is called multiple times in Oracle 11.2.0.4.
    Why is the constructor called multiple times?
    How do I stop it?
    My current work around is to reference the attributes and use the /*+ materialize */ hint.
    Problem Setup
        create or replace type Foo as object
          Bar1 NUMBER,
          Bar2 NUMBER,
          Bar3 NUMBER,
          CONSTRUCTOR FUNCTION Foo(p_Bar1 NUMBER, p_Bar2 NUMBER, p_Bar3 NUMBER)
            RETURN SELF AS RESULT
            DETERMINISTIC
        create or replace type body Foo is
          -- Member procedures and functions
          CONSTRUCTOR FUNCTION Foo(p_Bar1 NUMBER, p_Bar2 NUMBER, p_Bar3 NUMBER)
            RETURN SELF AS RESULT
            DETERMINISTIC
          AS
          BEGIN
            SELF.Bar1 := p_Bar1;
            SELF.Bar2 := p_Bar2;
            SELF.Bar3 := p_Bar3;
            dbms_output.put_line('Foo Constructor Called');
            RETURN;
          END;
        end;
    Problem
        -- Constructor is called 6 times!
        -- Once for each column and once for each predicate in the where clause.
        SELECT x.f.bar1 AS bar1, x.f.bar2 AS bar2, x.f.bar3 AS bar3, f
        FROM (
          SELECT foo(p_Bar1 => 1, p_Bar2 => 2, p_Bar3 => 3) f
          FROM dual d
        ) x
        WHERE x.f.bar1 = x.f.bar1 AND x.f.bar2 = x.f.bar2
    Output
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Workaround
        -- Work Around
        -- Constructor is called 3 times
        -- Once for each column in the inline view.
        -- Note, I removed column f (the object type) because it's not compatible with the materialize hint.
        WITH y AS (
          SELECT /*+ materialize */ x.f.bar1 AS bar1, x.f.bar2 AS bar2, x.f.bar3 AS bar3
          FROM (
            SELECT foo(p_Bar1 => 1, p_Bar2 => 2, p_Bar3 => 3) f
            FROM dual d
          ) x
        SELECT y.bar1, y.bar2, y.bar3
        FROM y
        WHERE y.bar1 = y.bar1 AND y.bar2 = y.bar2

    Another work-around is described in this thread... Accessing fields of a custom object type... which makes use of a collection type combined with the TABLE operator, like so...
    create or replace type FooTable as table of Foo;
    SELECT x.bar1 AS bar1, x.bar2 AS bar2, x.bar3 AS bar3, value(x) f
        FROM table(FooTable(
          foo(p_Bar1 => 1, p_Bar2 => 2, p_Bar3 => 3)
        )) x
        WHERE x.bar1 = x.bar1 AND x.bar2 = x.bar2
    BAR1 BAR2 BAR2 F
    1    2    3    (1, 2, 3)
    Foo Constructor Called
    Hope that helps...
    Gerard

  • 8.1.7 jdbc driver: object types with double quotes

    Hi all,
    While switching from 8.1.6 to 8.1.7 I have trouble with the jdbc driver. It doesn't work
    as before: The function CallableStatement.registerOutParameter (and probably some other) doesn't take object type
    names in double quotes anymore. A test program is appended to this message. Using a 8.1.6 jdbc driver this program works fine but with a 8.1.7 jdbc driver it throws an exception.
    My questions are: Is this bug already filed?
    Is a bugfix already available somewhere?
    Thanks in advance for any information
    Joerg
    import java.sql.*;
    * create type "test_t" as object (atrb number(10));
    * create table "test" of "test_t" (atrb not null) oidindex();
    class test
    public static void main (String args [])
    throws SQLException
    String s = "begin insert into \"test\" t values (1)" +
    " returning ref(t) into ?; end;";
    try{
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@host:1521:orcl","joerg", "password");
    CallableStatement cs = conn.prepareCall( s );
    cs.registerOutParameter(1, Types.REF, "\"test_t\"");
    cs.execute();
    System.out.println("Statement returned:");
    System.out.println( cs.getObject(1) );
    cs.close();
    conn.commit();
    conn.close();
    catch(SQLException e){
    System.out.println("SQLException was thrown...");
    System.out.println(e.getMessage());
    }

    I believe that typenames are always treated as case sensitive (unless they are all uppercased).
    In your example you should write:
    cs.registerOutParameter(1, Types.REF, "test_t");
    If you had declared the type test_t in a case insensitive way (without "..."), then you'd have to write:
    cs.registerOutParameter(1, Types.REF, "TEST_T");
    If you have a schema-qualified name, use a ".":
    cs.registerOutParameter(1, Types.REF, "SCOTT.test_t");
    However, this behavior implies that you cannot use "." inside of quoted identifier names.

Maybe you are looking for

  • Having problem with loading Oracle 8.1.7 on Linux-Mandrake 8.0

    I have done all necessary files that needed to be downloaded and installed. When i try to run "./runInstaller" it gave me an error saying that a whole bunch of files were unowned and on top it would say System Monitor ok. Please help....Thanks

  • HT5372 How do I get the blackrain application in iCloud?

    How do I get the blackrain application in ICloud?

  • Expressions in Alerting Email

    Hi, We have alerting set up and its working fine. I want to get some extra values on the email and I'm trying to use Expressions. Under Alrtcatdef when editing the Long text for the email there is a button under the text box called "Insert Expression

  • My iPhone 4s screen is blue, what's wrong?

    HI, about two weeks ago, I dropped my iPhone and the screen went black with blue vertical Stripes, within these two weeks, I have hoped something would change, but it is exactly the same. Please note that I have tried to reset it, and no change, I am

  • Assigning user status to order type

    Hi All, There is an query. Can I assign 2 user statuses to an order type? regards, Mohit Goyal