View Object with User Defined Type input

I am trying to use a View Object with a query that requires a user defined object as an input parameter.
I have the query working with a PreparedStatement, but would like to use a View Object.
When I use the PreparedStatement, I prepare the user defined type data like this:
// get the data into an object array
Object[] wSRecObjArr = wSRec.getObjectArray();
// set up rec descriptor
StructDescriptor WSRecDescriptor = StructDescriptor.createDescriptor("WS_REC",conn);
// populate the record struct
STRUCT wSRecStruct = new STRUCT(WSRecDescriptor,conn,wSRecObjArr);
Then I can use this in the PreparedStatement like this:
OraclePreparedStatement stat = null;
ResultSet rs = null;
stat = (OraclePreparedStatement)conn.prepareStatement("Select test_pkg.test_function(?) FROM DUAL");
stat.setSTRUCT(1, wSRecStruct);
rs = stat.executeQuery();
I would like to do the same process with a View Object instead of the PreparedStatement.
My question is "How do I create the input objects"?
I obtain the View Object from the Application Module using findViewObject(). I don't actually have a connection object to pass into the StructDescriptor.createDescriptor method.
I have tried just using Java Object Arrays (Object[]) to pass the data, but that gave an error:
oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation.
Any help or pointers are greatly appreciated.
Thank you.
Edited by: 942120 on May 1, 2013 8:45 AM
Edited by: 942120 on May 1, 2013 8:46 AM
Edited by: 942120 on May 1, 2013 9:05 AM
Edited by: 942120 on May 1, 2013 9:06 AM

Custom domains are the way to go.
When I try to pass custom domains that represent my user defined types - it works.
However, one of the functions requires a table of a user defined type be passed in.
I tried creating a domain of the table type. It forces me to add a field during creation (in JDEV), so I tried adding a field of type Array of Element of the domain representing the user defined type.
I populate the table by setting the field I created, but the table is empty in PL/SQL (TEST_TAB.COUNT = 0).
I also tried passing the oracle.jbo.domain.Array object, but that produced an error:
java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call
I also tried passing Object[], but that produced an error:
oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation.
How do I properly create, and pass an domain that represents a table of a user defined type?
When I use a OraclePreparedStatement, I can pass a oracle.sql.ARRAY using stat.setARRAY.
Thank you for the help you have provided, and any future advice.
JDEV 10.1.2.3
JDBC 10.2.0.5
Edited by: 942120 on May 13, 2013 7:13 AM
Edited by: 942120 on May 13, 2013 7:16 AM

Similar Messages

  • Problem calling stored procedure with user-defined type of input parameters

    Hi,
    I have to call a stored procedure with IN parameters, but these are user-defined types of input parameters.
    function fv_createnews (
    pit_groups in T_APPLICATION_USER_GROUPS,
    pit_documents in T_DOCUMENTS
    return varchar2;
    TYPE T_APPLICATION_USER_GROUPS IS
    TABLE OF varchar2(500)
    INDEX BY binary_integer;
    TYPE T_DOCUMENT IS record (
    name varchar2(256)
    ,url varchar2(1024)
    ,lang varchar2(30)
    ,foldername varchar2(150)
    TYPE T_DOCUMENTS IS
    TABLE OF T_DOCUMENT
    INDEX BY binary_integer;
    How can I do this using the TopLink 10.1.3 API.
    I already found following related posts, but I still can' t make it up:
    Using VARRAYs as parameters to a Stored Procedure
    Pass Object as In/Out Parameter in Stored Procedure
    Or do I have to create my own PreparedStatement for this special stored procedure call using Java and Toplink?

    As the related posts suggest, you will need to use direct JDBC code for this.
    Also I'm not sure JDBC supports the RECORD type, so you may need to wrap your stored functions with ones that either flatten the record out, or take OBJECT types.

  • Notification with user defined type results in PLS-00306: wrong number..

    I created a user defined type TLogMessage:
    CREATE OR REPLACE TYPE TLogMessage AS OBJECT
    module VARCHAR2(4000),
    severity NUMBER,
    message VARCHAR2(4000)
    I also created a multi-consumer queue using this type as payload.
    My callback procedure in the package PK_SYST_LOGMESSAGE is defined as follows:
         PROCEDURE DefaultLoggerCallback(
              context          RAW,
              reginfo          SYS.AQ$_REG_INFO,
              descr          SYS.AQ$_DESCRIPTOR,
              payload          RAW,
              payload1     NUMBER
    Finally, I registered the callback procedure as follows:
              DBMS_AQADM.ADD_SUBSCRIBER(
                   queue_name      => QUEUE_NAME,
                   subscriber      => SYS.AQ$_AGENT(
                                            name => 'default_logger',
                                            address => NULL,
                                            protocol => NULL
              DBMS_AQ.REGISTER(
                   SYS.AQ$_REG_INFO_LIST(
                        SYS.AQ$_REG_INFO(
                             name          => QUEUE_NAME || ':default_logger',
                             namespace     => DBMS_AQ.NAMESPACE_AQ,
                             callback     => 'plsql://MTDX.PK_SYST_LOGMESSAGE.DefaultLoggerCallback',
                             context          => HEXTORAW('FF')
                   1
    However, when I put a message in the queue using this procedure:
         PROCEDURE LogMessage(
              pModule          VARCHAR2,
              pSeverity     NUMBER,
              pMessage     VARCHAR2
         IS
              vMessage               TLogMessage;
              vEnqueueOptions          DBMS_AQ.ENQUEUE_OPTIONS_T;
              vMsgProperties          DBMS_AQ.MESSAGE_PROPERTIES_T;
              vMessageHandle          RAW(16);
         BEGIN
              vMessage := TLogMessage(module => pModule, severity => pSeverity, message => pMessage);
              vEnqueueOptions.visibility := DBMS_AQ.IMMEDIATE;
              vMsgProperties.correlation := pModule;
              vMsgProperties.priority := -pSeverity;
              -- Enqueue the message to all subscribers
              DBMS_AQ.ENQUEUE(
                   queue_name               => QUEUE_NAME,
                   enqueue_options          => vEnqueueOptions,
                   message_properties     => vMsgProperties,
                   payload                    => vMessage,
                   msgid                    => vMessageHandle
         EXCEPTION
              WHEN no_subscribers THEN
                   -- No subscribers on the queue; ignore
                   NULL;
         END;
    I can see the message in the queue, by querying the queue view. I can also see that Oracle tried to call my callback procedure, because in the trace file I see the following:
    *** 2009-02-13 08:52:25.000
    *** ACTION NAME:() 2009-02-13 08:52:24.984
    *** MODULE NAME:() 2009-02-13 08:52:24.984
    *** SERVICE NAME:(SYS$USERS) 2009-02-13 08:52:24.984
    *** SESSION ID:(609.3387) 2009-02-13 08:52:24.984
    Error in PLSQL notification of msgid:4F7962FEDD3B41FA8D9538F0B38FCDD1
    Queue :"MTDX"."LOGMESSAGE_QUEUE"
    Consumer Name :DEFAULT_LOGGER
    PLSQL function :MTDX.PK_SYST_LOGMESSAGE.DefaultLoggerCallback
    : Exception Occured, Error msg:
    ORA-00604: Fout opgetreden bij recursief SQL-niveau 2.
    ORA-06550: Regel 1, kolom 7:
    PLS-00306: Onjuist aantal of type argumenten in aanroep naar 'DEFAULTLOGGERCALLBACK'..
    ORA-06550: Regel 1, kolom 7:
    PL/SQL: Statement ignored.
    So.. how many parameters does Oracle expect, and of what type? Is there any way to find out? What is wrong with my code?

    Ok, found it... I had defined the last parameter of the callback procedure as 'payload1' (that is: 'payload-ONE') instead of 'payloadl' ('payload-ELL'). It all works like a charm now.
    What a way to waste two whole days!

  • Deploying c# procedure with user-defined type

    Hi
    I've written a c# procedure which makes use of some Oracle user-defined types (c# classes generated using the wizard).
    I will be calling the procedure from an Oracle package and one of the out parameters needs to be one of my user defined Oracle objects (basically a record object). My problem is when I come to deploy the package, it tells me "... does not contain any .NET stored procedures that can be deployed to Oracle"
    If I change the user defined type (out param) to something like an Int32 or string, it works fine. AFAIK the latest version of ODT/ODAC supports user defined types. For Info I've 11g Client , .Net v4 & VS2010
    quick example of procedure entry point.
    works:
    public static void GetOrderCost(int OrderNr, out Int32 orderCost )
    Not work:
    public static void GetOrderCost(int OrderNr, out ORDER_RECORD orderCost ) - Note: ORDER_RECORD is the class created using the class generation wizard.
    I've spent 2 days now trying to get this to work, perhaps its not possible or perhaps my setup is not quite right but any help gratefully received.
    Ian

    think I have found some small print which scuppers my plan. Good if some one could confirm and nicer if someone could suggest a workaround (without resorting to writing the UDT to a Oracle table)
    Oracle User-Defined Type (UDT) Support
    UDTs are not supported within a context connection but they are supported with a client connection. UDTs are not supported as parameters to .NET stored procedures.
    Source:
    http://docs.oracle.com/cd/E14435_01/win.111/e10927/extenRest.htm#CJAHJBJI
    So you can use UDT's within the body of the procedure (and can read them off the DB) but as yet its not possible to use them as parameters.

  • Selecting Columns with User Defined Types... in PHP

    I've looked all over google and this forum and can't find anything about this... here's what I've got:
    a User Defined Type:
    CREATE TYPE "ADDRESS" AS OBJECT (
    ADDRESS VARCHAR2(256),
    COUNTRY VARCHAR2(256),
    STATE VARCHAR2(256),
    SUBURB VARCHAR2(256),
    TOWNCITY VARCHAR2(256)
    and it is used in a column in one of my tables:
    CREATE TABLE "SUPPLIERS" (
    "ID" NUMBER,
    "USER_ID" NUMBER,
    "NAME" VARCHAR2(50),
    "ADDRESS" "ADDRESS"
    so that column "address" is of type "address". I am then able to insert a row using:
    INSERT INTO "SUPPLIERS" VALUES(1,1,'name',ADDRESS('address','country','state','suburb','town city'));
    and that all works as expected. I can select the data using iSqlPlus and get the result I expect;
    ADDRESS('address', 'country', 'state', 'suburb', 'town city')
    So here's the problem. I cannot reterieve the data as expected, using PHP. If I make a select statement on the table that excludes the ADDRESS column I get the results as expected. If the ADDRESS column is included I get an error when fetching the row:
    ORA-00932: inconsistent datatypes: expected CHAR got ADT
    I'm assuming this is because the the cell cannot be cast to a string. How can I select the row so that the ADDRESS column is returned as an object? Can I even? If I can't, I don't see the use of Object Data Types... :(
    I have found that I can select a field of the type using:
    SELECT t.ADDRESS.TOWNCITY FROM SUPPLIERS t;
    But this is not ideal, because the whole idea was that I could (potentially) change the format for, in my example, an address, and not need to alter my SQL statements.
    Any ideas??

    PHP OCI8 can currently only bind simple types. Here are two possible
    solutions.
    -- cj
    create or replace type mytype as object (myid number, mydata varchar2(20));
    show errors
    create or replace type mytabletype as table of mytype;
    show errors
    create or replace procedure mycreatedata1(outdata out mytabletype) as
    begin
      outdata := mytabletype();
      for i in 1..10 loop
        outdata.extend;
        outdata(i) := mytype(i, 'some name'||i);
      end loop;
    end;
    show errors
    -- Turn the data into a ref cursor (but PHP OCI8 doesn't use prefetching for ref cursors)
    create or replace procedure mywrapper1(rcemp out sys_refcursor) as
    data mytabletype;
    begin
      mycreatedata1(data);
      open rcemp for select * from table(cast(data as mytabletype));
    end mywrapper1;
    show errors
    -- Turn the data into two collections
    -- This might be faster than returning a ref cursor because you can
    -- use oci_bind_array_by_name() on each parameter.
    create or replace procedure mywrapper2(pempno out dbms_sql.NUMBER_table, pename out dbms_sql.VARCHAR2_table) as
    data mytabletype;
    begin
      mycreatedata1(data);
      select myid, mydata
      bulk collect into pempno, pename
      from table(cast(data as mytabletype));
    end mywrapper2;
    show errorsThen in PHP you could do:
    // Use a Ref Cursor
    $s = oci_parse($c, "begin mywrapper1(:myid); end;");
    $rc = oci_new_cursor($c);
    oci_bind_by_name($s, ':myid', $rc, -1, OCI_B_CURSOR);
    oci_execute($s);
    oci_execute($rc);
    oci_fetch_all($rc, $res);
    var_dump($res);
    // Use Collections
    $s = oci_parse($c, "begin mywrapper2(:myid, :mydata); end;");
    oci_bind_array_by_name($s, ":myid", $myid, 10, -1, SQLT_INT);
    oci_bind_array_by_name($s, ":mydata", $mydata, 10, 20, SQLT_CHR);
    oci_execute($s);
    var_dump($myid);
    var_dump($mydata);

  • How to use OracleDbType.Array provided by ODP with  User defined type ?

    Can anyone help me how to use OracleDbType.Array provided by ODP.NET ?
    I need to pass string array to a oracle stored procedure .
    User defined array type defined in oracle is :
    CREATE TYPE TYPE_NAME IS TABLE OF varchar2(20) ;
    This type is defined outside of any package , and i have tested that if definition of type is modified to
    CREATE TYPE TYPE_NAME IS TABLE OF varchar2(20) index by binary_integer , i am able to pass array as AssociativeArray to my Stored Procedure.
    But how to pass array object if the Type's definition does not contain index by clause ?
    Please help how to pass Array object to Oracle Stored Procedure ?

    The solution described in Passing Array of UDT or Collection as IN OUT using OracleDbType.InputOutput
    is working for me.
    Edited by: stzueger on Jan 2, 2012 10:32 AM

  • ALV view : Problem with user defined views

    Dear Experts,
    We are facing a problem pertaining to user defined views for a ALV table that we have in SAP eRecruiting application in webdynpro ABAP. The problem is as follows.
    There is a candidate application ABC & only ONE person can edit this at a time.In this application ABC there is a ALV table.
    If the user clicks on this application & navigates to the ALV,this ABC application is in normal/edit mode(no one else has opened this ). So, the user can make changes in ABC. In the ALV, he can click on the 'settings 'button and save the STANDARD view as his own user defined view(by adding or removing columns).
    If the user opens the application ABC in display mode(implying that someone else has alraedy opened ABC for editing), when i navigate to the same ALV,the user CANNOT see the views which were saved in the edit mode.Only the standard view is displayed. The user however has the option to again freshly save a view.
    The views created by a user for this ALV should be seen irrespective of the application being opened in normal or display mode.
    To add to the confusion, this problem is occuring only in some systems & not in others. There is atleast one system where the views are displayed correctly to the user.
    On debugging, the table wdy_conf_user has config ids as different where the user views are stored separately for display & edit mode.
    In systems where the user views are displayed correctly, the config id is one & the same ensuring that the user can see all his views irrespective of the mode of the application.
    Any thoughts on how we can rectify this?
    sorry for the long & tedious explanation
    Thanks in advance,
    Sowmya

    See
    michaels>  select xmlquery('declare function local:test_function($namecmp as xs:string?, $inputtype as xs:string?) as xs:string?      
                        return {$inputtype}
                     local:test_function("1","2")' returning content) o from dual
    Error at line 5
    ORA-19114: error during parsing the XQuery expression:
    LPX-00801: XQuery syntax error at '{'
    3                       return {$inputtype}
    -                              ^
    michaels>  select xmlquery('declare function local:test_function($namecmp as xs:string?, $inputtype as xs:string?) as xs:string?      
                        $inputtype
                     local:test_function("1","2")' returning content) o from dual
    O   
    2   
    1 row selected.

  • How to execute function takes user defined type parameters as input &output

    Hi All,
    I want to execute a function which takes user defined type as input & output parameters. But i don't know how to execute that function in pl/sql statements.
    CREATE TYPE T_INPUT AS OBJECT
    USER          VARCHAR2(255),
    APPLICATION     VARCHAR2(255),
    REFERENCE          VARCHAR2(30)
    ) NOT FINAL;
    CREATE TYPE T_ID UNDER T_INPUT
    E_ID                    VARCHAR2 (50),
    CODE                    VARCHAR2 (3),
    SERVICE                    VARCHAR2 (10),
    C_TYPE                    VARCHAR2 (1)
    ) NOT FINAL;
    CREATE TYPE T_OUTPUT AS OBJECT
         R_STATUS               NUMBER(10),
         E_DESC_LANG_1          VARCHAR2(1000),
         E_DESC_LANG_2          VARCHAR2(1000),
         A_REFERENCE          VARCHAR2(30)
    ) NOT FINAL;
    CREATE TYPE T_INFO UNDER T_OUTPUT
    E_INFO XMLTYPE
    CREATE FUNCTION Get_Dtls
    I_DETAILS IN T_ID,
    O_DETAILS OUT T_INFO
    RETURN NUMBER AS
    END;
    Here
    1. T_ID is an input parameter which is a combination of T_ID + T_INPUT,
    2. T_INFO is an output parameter which is a combination of T_INFO + T_OUTPUT.
    Here i'll assign the T_ID values.
    --- T_INPUT values
    USER          = "admin";
    APPLICATION     = "test";
    REFERENCE     = "null";
    ---- T_ID values
    E_ID               = "1234";
    CODE               = "TTT";
    SERVICE               = "NEW";
    C_TYPE = "P";
    Now i want to execute Get_Dtls function with T_ID,T_INFO parameters in pl/sql statements.
    I want to catch the E_INFO value from T_INFO type.
    How can i Do this ?
    Pls Help. Thanxs in advance.
    Anil.

    I am very new to this. New to Oracle, PL/SQL, OO programming or testing?
    set serveroutput on
    declare
      tst_obj ctype;
    begin
      tst_obj := pkg.proc(11);
      dbms_output.put_line('id='||tst_obj.id||'::code='||tst_obj.code||'::usage='||tst_obj.usage);
    end;
    /Generally I disapprove of the use of DBMS_OUTPUT (for just about anything) but it is sufficient to demonstrate the basic principle.
    Really you should start using proper testing practices, ideally with an automated test harness like QUTE.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • Inserting a new row in a BC4J View Object with an attribute of type BFileDomain

    Hi all,
    I've to insert a row in a View Object with an attribute of type oracle.jbo.domain.BFileDomain.
    I do this within an Application Module's method, which has an input parameter of type byte[]. This parameter will be the content of the BFILE.
    What's the right way for doing that?
    I've tried with the following code, but I've got an exception in committing the transaction:
    public int serializeDocument(int codDomanda, int codSorgente, byte[] content, String est, int type, int cost, String title, String arg) throws JboException {
    int code = 0;
    //File f;
    DocumentiTwoView = getDocumentiTwoView();
    java.sql.Statement stmt = ((DBTransaction) getTransaction()).createStatement(1);
    try {
    Row docRow = DocumentiTwoView.createRow();
    SequenceImpl seq = new SequenceImpl("documenti_seq", getDBTransaction());
    Integer next = (Integer) seq.getData();
    code = next.intValue();
    docRow.setAttribute("Coddocumento", new Number(code));
    docRow.setAttribute("Titolo", (String) title);
    docRow.setAttribute("Argomento", (String) arg);
    docRow.setAttribute("Costo", new Number(cost));
    docRow.setAttribute("Tipo", new Number(type));
    docRow.setAttribute("Coddomanda", new Number(codDomanda));
    docRow.setAttribute("Codsorgente", new Number(codSorgente));
    //f = new File("Doc" + code + "." + est)
    BFILE src_lob = null;
    ResultSet rset = null;
    rset = stmt.executeQuery ("SELECT BFILENAME('DOC_DIR', 'Doc" + code + "." + est + "') FROM DUAL");
    if (rset.next()) {
    src_lob = ((OracleResultSet)rset).getBFILE(1);
    BFileDomain bfd = new BFileDomain(src_lob);
    bfd.setBytes(content);
    bfd.saveToDatabase(getTransaction());
    docRow.setAttribute("Contenuto", (BFileDomain) bfd);
    catch (Exception ex) {
    getTransaction().rollback();
    throw new oracle.jbo.JboException("Impossibile creare il nuovo documento:\n" + ex.getMessage());
    finally {
    try {
    stmt.close();
    catch (Exception nex) {
    try {
    // Commit the whole transaction
    getTransaction().commit();
    catch (Exception e) {
    e.printStackTrace();
    getTransaction().rollback();
    throw new JboException("Impossibile eseguire il commit della transazione:\n" + e.getMessage());
    return code;
    Thanks a lot in advance!
    Christian
    null

    Odd, have you disabled caching and indirection? (NoIdentityMap, dontUseIndirection, or alwaysRefresh/disableCacheHits). If so, then this could be the issue.
    Otherwise please include the sample code you use to perform this, and verify that you do not have any unusual code in your set/get methods or in descriptor events. Also turn TopLink logging on and include a sample. Also ensure that you do not modify your objects until after registering them in the unit of work, and only modify the unit of work clones.

  • Oracle 11g AQ : problem enqueue user-defined type with varchar2 attribute

    Hello.
    I have a problem enqueuing a user-defined type to the queue on Oracle 10g.
    I'm using jdbc driver (ojdbc5.jar, version 11.1.0.6.0) as they provide oracle.jdbc.aq package.
    The type is following:
    CREATE OR REPLACE TYPE FIXED_T5 AS OBJECT
    (id integer,
    label varchar2(100),
    code integer,
    today date
    )I have created a java class for this type with jpub utility supplied with oracle 11g client package:
    jpub -user=scott/tger -url=jdbc:oracle:thin:@host:sid-sql=FIXED_T5:ru.invito.FixedType -compile=falseIt generated FixedType.java and FixedTypeRef.java files. Don't understand why i need the latter (FixedTypeRef).
    Then in test app:
    package ru.invito;
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.UnknownHostException;
    import java.sql.SQLException;
    import java.sql.Timestamp;
    import java.util.Date;
    import java.util.Properties;
    import java.util.UUID;
    import junit.framework.TestCase;
    import oracle.jdbc.aq.AQAgent;
    import oracle.jdbc.aq.AQEnqueueOptions;
    import oracle.jdbc.aq.AQFactory;
    import oracle.jdbc.aq.AQMessage;
    import oracle.jdbc.aq.AQMessageProperties;
    import oracle.jdbc.aq.AQEnqueueOptions.DeliveryMode;
    import oracle.jdbc.aq.AQEnqueueOptions.VisibilityOption;
    import oracle.jdbc.driver.OracleConnection;
    import oracle.jdbc.driver.OracleDriver;
    import oracle.sql.Datum;
    import oracle.sql.STRUCT;
    import oracle.sql.StructDescriptor;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class AqTest extends TestCase {
         protected Log logger = LogFactory.getLog(getClass());
         public void testEnqueue() throws Exception {
              OracleDriver dr = new OracleDriver();
              Properties prop = new Properties();
              prop.setProperty("user", Config.USERNAME);
              prop.setProperty("password", Config.PASSWORD);
              OracleConnection connection = (OracleConnection) dr.connect(Config.JDBC_URL, prop);
              assertNotNull(connection);
              connection.setAutoCommit(false);
              enqueueMessage(connection, "INVITO.FIXED_T5Q", null);
              connection.commit();
         private void enqueueMessage(OracleConnection conn, String queueName, AQAgent[] recipients) throws SQLException,
                   IOException {
              logger.debug("----------- Enqueue start ------------");
              AQMessageProperties props = makeProps(queueName);
              AQMessage mesg = AQFactory.createAQMessage(props);
              String msqText = String.format("Hello, %s!", queueName);
              FixedType data = createData(36, msqText);
              Datum d = data.toDatum(conn);
              STRUCT s = (STRUCT) d;
              debugStruct("s", s);
              String toIdStr = byteBufferToHexString(s.getDescriptor().getOracleTypeADT().getTOID(), 20);
              logger.debug("s.toIdStr: " + toIdStr);
              StructDescriptor sd = StructDescriptor.createDescriptor("INVITO.FIXED_T5", conn);
              logger.debug("sd.toXMLString(): " + sd.toXMLString());
              mesg.setPayload(s);
              AQEnqueueOptions opt = makeEnqueueOptions();
              logger.debug("sending............");
              // execute the actual enqueue operation:
              conn.enqueue(queueName, opt, mesg);
              debugMessageId(mesg);
              logger.debug("----------- Enqueue done ------------");
         private void debugMessageId(AQMessage mesg) throws SQLException {
              byte[] mesgId = mesg.getMessageId();
              if (mesgId == null) {
                   throw new IllegalStateException("message id is NULL");
              String mesgIdStr = byteBufferToHexString(mesgId, 20);
              logger.debug("Message ID from enqueue call: " + mesgIdStr);
          * @return
          * @throws SQLException
         private FixedType createData(int ID, String label) throws SQLException {
              FixedType data = new FixedType();
              data._struct.setNChar(1);// initializes the flag for 'label' field
              data.setId(ID);
              data.setLabel(label);
              data.setCode(1);
              Date today = new Date();
              data.setToday(new Timestamp(today.getTime()));
              return data;
          * @param string
          * @param s
          * @throws SQLException
         private void debugStruct(String string, STRUCT s) throws SQLException {
              logger.debug(s + ".debugString(): " + s.debugString());
              logger.debug(s + "s.dump(): " + s.dump());
          * @return
          * @throws SQLException
         private AQAgent makeAgent() throws SQLException {
              AQAgent ag = AQFactory.createAQAgent();
              ag.setName("AQ_TEST");
              String agentAddress = null;
              try {
                   agentAddress = InetAddress.getLocalHost().getHostAddress();
              catch (UnknownHostException e) {
                   logger.error("cannot resolve localhost ip address. will not set it as AQ Agent address");
                   agentAddress = "NA";
              ag.setAddress(agentAddress);
              return ag;
         private AQMessageProperties makeProps(String queueName) throws SQLException {
              final String EXCEPTION_Q_TEMPLATE = "AQ$_%sT_E";
              final int DEFAULT_DELAY = 0;
              final int DEFAULT_EXPIRATION = -1;
              final int DEFAULT_PRIORITY = 0;
              AQMessageProperties propeties = AQFactory.createAQMessageProperties();
              propeties.setCorrelation(UUID.randomUUID().toString());
              propeties.setDelay(DEFAULT_DELAY);
              propeties.setExceptionQueue(String.format(EXCEPTION_Q_TEMPLATE, queueName));
              propeties.setExpiration(DEFAULT_EXPIRATION);
              propeties.setPriority(DEFAULT_PRIORITY);
              // propeties.setRecipientList(null);//should not set
              propeties.setSender(makeAgent());
              return propeties;
          * @return
          * @throws SQLException
         private AQEnqueueOptions makeEnqueueOptions() throws SQLException {
              AQEnqueueOptions opt = new AQEnqueueOptions();
              opt.setRetrieveMessageId(true);
              // these are the default settings (if none specified)
              opt.setDeliveryMode(DeliveryMode.PERSISTENT);
              opt.setTransformation(null);
              opt.setVisibility(VisibilityOption.ON_COMMIT);
              return opt;
          * Form the AQ reference
          * @param buffer
          * @param maxNbOfBytes
          * @return
         private static final String byteBufferToHexString(byte[] buffer, int maxNbOfBytes) {
              if (buffer == null)
                   return null;
              int offset = 0;
              StringBuffer sb = new StringBuffer();
              while (offset < buffer.length && offset < maxNbOfBytes) {
                   String hexrep = Integer.toHexString((int) buffer[offset] & 0xFF);
                   if (hexrep.length() == 1)
                        hexrep = "0" + hexrep;
                   sb.append(hexrep);
                   offset++;
              String ret = sb.toString();
              return ret;
    }The output is following:
    [main] 2008-07-03 19:09:49,863 DEBUG [ru.invito.AqTest] - ----------- Enqueue start ------------
    [main] 2008-07-03 19:09:50,348 DEBUG [ru.invito.AqTest] - [email protected](): name = INVITO.FIXED_T5 length = 4 attribute[0] = 36 attribute[1] = Hell
    o, INVITO.FIXED_T5Q! attribute[2] = 1 attribute[3] = 2008-07-03 19:09:49.0
    [main] 2008-07-03 19:09:50,363 DEBUG [ru.invito.AqTest] - [email protected](): name = INVITO.FIXED_T5
    length = 4
    ID = 36
    LABEL = Hello, INVITO.FIXED_T5Q!
    CODE = 1
    TODAY = 2008-07-03 19:09:49.0
    [main] 2008-07-03 19:09:50,363 DEBUG [ru.invito.AqTest] - s.toIdStr: 507ccce5b6e9f572e040007f01007203
    [main] 2008-07-03 19:09:50,363 DEBUG [ru.invito.AqTest] - sd.toXMLString(): <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <StructDescriptor sqlName="INVITO.FIXED_T5" >
      <OracleTypeADT sqlName="INVITO.FIXED_T5"  typecode="0" tds_version="1"
               is_embedded="false" is_top_level="true" is_upt="false" finalType="true" subtype="false">
        <attributes>
          <attribute name="ID"  type="INTEGER" >
            <OracleType typecode="2" />
          </attribute>
          <attribute name="LABEL"  type="VARCHAR2" >
            <OracleType typecode="12" />
          </attribute>
          <attribute name="CODE"  type="INTEGER" >
            <OracleType typecode="2" />
          </attribute>
          <attribute name="TODAY"  type="DATE" >
            <OracleType typecode="0" />
          </attribute>
        </attributes>
      </OracleTypeADT>
    </StructDescriptor>
    [main] 2008-07-03 19:09:50,379 DEBUG [ru.invito.AqTest] - sending............
    [main] 2008-07-03 19:09:50,395 DEBUG [ru.invito.AqTest] - Message ID from enqueue call: 511ff143bd4fa536e040007f01003192
    [main] 2008-07-03 19:09:50,395 DEBUG [ru.invito.AqTest] - ----------- Enqueue done ------------But when dequeueing the 'label' attribute is lost:
    DECLARE
    dequeue_options     DBMS_AQ.dequeue_options_t;
    message_properties  DBMS_AQ.message_properties_t;
    message_handle      RAW(16);
    message             fixed_t5;
    BEGIN
      dequeue_options.navigation := DBMS_AQ.FIRST_MESSAGE;
      DBMS_AQ.DEQUEUE(
         queue_name          =>     'fixed_t5q',
         dequeue_options     =>     dequeue_options,
         message_properties  =>     message_properties,
         payload             =>     message,
         msgid               =>     message_handle);
      DBMS_OUTPUT.PUT_LINE('ID   : '||message.id);
      DBMS_OUTPUT.PUT_LINE('Label: '||message.label);
      DBMS_OUTPUT.PUT_LINE('Code : '||message.code);
      DBMS_OUTPUT.PUT_LINE('Today: '||message.today);
      COMMIT;
    END;
    ID   : 36
    Label:
    Code : 1
    Today: 03.07.08
    Could anyone tell me what is wrong with the setup/code?
    Why 'label' not saved in queue, though i saw it is not empty in STRUCT?

    Thank you for the reply!
    I have enqueued:
    [main] 2008-07-04 15:30:30,639 DEBUG [ru.invito.UserDefinedTypeAqTest$1] - [email protected](): name = INVITO.FIXED_T5
    length = 4
    ID = 41
    LABEL = Hello, INVITO.FIXED_T5Q!
    CODE = 1
    TODAY = 2008-07-04 15:30:30.0and in table (select * from FIXED_T5QT) the 'label' is blank:
    Q_NAME     FIXED_T5Q
    MSGID     51310809B5EA3728E040007F01000C79
    CORRID     b8f38fd3-4fa6-4e0f-85d1-2440d02d655e
    PRIORITY     0
    STATE     0
    DELAY     
    EXPIRATION     
    TIME_MANAGER_INFO     
    LOCAL_ORDER_NO     0
    CHAIN_NO     0
    CSCN     0
    DSCN     0
    ENQ_TIME     04.07.2008 15:28:44
    ENQ_UID     INVITO
    ENQ_TID                       4012
    DEQ_TIME     
    DEQ_UID     
    DEQ_TID     
    RETRY_COUNT     0
    EXCEPTION_QSCHEMA     AQ$_INVITO
    EXCEPTION_QUEUE     FIXED_T5QT_E
    STEP_NO     0
    RECIPIENT_KEY     0
    DEQUEUE_MSGID     
    SENDER_NAME     AQ_TEST
    SENDER_ADDRESS     10.1.1.137
    SENDER_PROTOCOL     
    USER_DATA.ID     41
    USER_DATA.LABEL     
    USER_DATA.CODE     1
    USER_DATA.TODAY     04.07.2008 15:30:30I must point to a strange thing: when the FixedType instance is created (via new operator) and then the setLabel("....") called as:
    FixedType data = new FixedType();
    // hack: proper initialization for 'label' field
    data._struct.setNChar(1);
    data.setId(ID);
    data.setLabel(label);
    data.setCode(1);
    Date today = new Date();
    data.setToday(new Timestamp(today.getTime()));
    Datum d = data.toDatum(connection);
    STRUCT s = (STRUCT) d;
    logger.debug(s + ".debugString(): " + s.debugString());
    logger.debug(s + ".dump(): " + s.dump());and if i comment line (data._struct.setNChar(1);) the debug messages for created STRUCT also shows empty value for label.
    But if i explicitly call data._struct.setNChar(1) then debug contains the label i defined in call to the setLabel method.

  • Object Diagrams that support user define type (create type....and subtypes

    Hello it would be very nice to be able to use user define types in a diagram, at this time oracle, ibm db2 9 and sql server 2005 suport sql ansi 2003 and to use all this potential we have to take tecnology foward. My sugestion is create object diagram that can help design all this funtionability, rational rose has the oracle8 addin this will give you an exact idea of what i am asking.
    Thanks for your atention and let me know if you are planing to do this.
    Perhaps this is not the right forum please tell me where I can send this as a future requests

    JDeveloper has a UML class diagram with transformation into a Java class diagram - are you looking for anything beyond that?

  • Invoking methods on JMX with user defined objects.

    Hello, All.
    Here is the problem description: We need to expose methods on JMX which takes some object of user defined class. We are not able to do that. Meaning, it is not getting enabled and if we invoke through code it says exception with serialization things. So we tried to make user defined class to implement serialization by making it to implement Serializable [though just adding serialization id]. But still we are getting the same problem. So I think we are missing some small step; as we are completely new this we are looking for some help in how to provide methods on jmx which accepts arguments of user defined type.
    Thanks,
    Prasanna.

    When executing an operation via JMX using JConsole, I get the following error:
    Problem invoking getManifest : java.rmi.UnmarshallException: Error unmarshalling return: nested is: java.lang.ClassNotFoundException: foo.bar.InernalServiceException (no security manager: RMI class loader disabled)
    Code snippet:
    public ArrayList getManifest(String s) throws InternalServiceException, MBeanException{
    String path = ".\\foo_services.jar"; // Invalid path on purpose to test exception...
    File file = new File(path);
    FileInputStream fileInput;
    try {
    fileInput = new FileInputStream(file);
    } catch (FileNotFoundException e) {
    String msg = "The manifest file is not found in the given path";
    if (logger.isErrorEnabled()) logger.error(msg);
    throw new InternalServiceException(msg, ErrorConstants.JMX_FILE_NOT_FOUND);
    If I throw new RuntimeException(msg, e) instead of InternalServiceException(msg, ErrorConstants.JMX_FILE_NOT_FOUND), it works and I get the appropriate exception.
    What is the reason for this?

  • Retain standard SAP order type after copying with user defined order type

    Hello SAP Gurus,
    We have a requirement of retaining the standard SAP order types after copying with User defined order types. But the issue is we don't want to see the standard SAP order type such as PM01, PM02 in production system while using transaction like IW31 etc.
    Is there anybody who has answer to retain these stanadard SAP order types without deleting from system configuration?
    Thanks in advance.
    Cheers,
    Vaibhav

    Vaibhav,
    When you F4 on the order type field in IW31 you will get the popup showing the order type list. At the top of this list is a button with a green "+" sign (Insert in personal list).
    You can use this button to select your favourite list.
    This function is available in most F4 drop-down lists.
    However, you cannot set this setting for all users. You will need to write an ABAP program to do this.
    PeteA

  • Using stored procedure with Oracle user-defined types in database control

    Hi,
    I have a requirement where I need to call an Oracle Stored Proc which has IN and OUT parameters. OUT parameters are of user-defined types in Oracle packages.
    I am getting error while calling the Stored proc like below:
    Procedure:
    ==========
    create or replace
    PROCEDURE AA_SAM_TEST (
    col1 out types_aa.aa_tex_type ,
    col2 out types_aa.aa_tex_type ,
    col2 out types_aa.aa_num_type ) As
    Types:
    ======
    create or replace
    package types_aa as
    type aa_tex_type is table of varchar2(255) index by binary_integer;
    type aa_num_type is table of char index by binary_integer;
    end
    Wli Code:
    =========
    DB Control:
    ===========
    * @jc:sql statement="call AA_SAM_TEST(?,?,?)"
    void Call_AA_SAM_TEST(SQLParameter[] param) throws SQLException;
    JPD Code:
    =========
    param = new SQLParameter[3];
    Object param1 = new String();
    Object param2 = new String();
    Object param3 = new String();
    this.param[0] = new SQLParameter(param1 , Types.STRUCT, SQLParameter.OUT);
    this.param[1] = new SQLParameter(param2, Types.STRUCT, SQLParameter.OUT);
    this.param[2] = new SQLParameter(param3, Types.STRUCT, SQLParameter.OUT);
    database_Update.Call_AA_SAM_TEST(this.param);
    I am getting the following error...
    <Jul 24, 2007 6:47:42 PM IST> <Warning> <WLW> <000000> <Id=database_Update; Method=Ctrl_files.Database_Update.Call_AA_SAM_TEST(); Failure=java.sql.SQLException: ORA-06553: PLS-:
    ORA-06553: PLS-:
    ORA-06553: PLS-:
    ORA-06553: PLS-:
    ORA-06553: PLS-:
    ORA-06553: PLS-306: wrong number or typ
    ORA-06553: PLS-306: wrong number or types of arguments in call to 'AA_SAM_TEST'
    ORA-06553: PLS-306: wrong number or types of arguments in call to 'AA_SAM_TEST'
    Can anyone know how to specify OUT parameter of USer-Defined types while using a DB control to access a Stored Proc in Oracle.
    Any help is highly appreciated.
    Thanks

    Hi,
    I have similar problem. Have you already solved the issue?
    Thanks

Maybe you are looking for

  • What is the safe music listening level for regular and in-ear headphones?

    I am wondering what the safe music listening level for regular and in-ear headphones is. I heard it was 50% volume for regular headphones but what about the new 60$ in-ear ones? I am going to get them soon.

  • Any thoughts on tackling a lack of free space on hard drive?

    Photoshop Elements 9 has left me with little free space on my hard drive.  Per my conversation with Adobe tech support, an external hard drive (which I currently do not own) should not be used to run Photoshop 9, but rather I should move my pictures

  • IM & Presence migration: 9.1(2) to 10.5(2)

    Hi, We are migrating our IM&P (along with CUCM) from 9.1(2) to 10.5(2). Using PCD for upgrade. We go the CUCM upgrade files using the PUT tools. Cannot find the files for IM & P upgrade. PCD accepts the CUCM file as valid upgrades for Unity and CUCM.

  • Macbook pro (late 2013) states it has ddr3 and not ddr3l.

    Does anyone actually see DDR3L in the system information?  I know they're supposed to come with ddr3l.

  • In to out

    Hello, I am wondering if it is possible to select the Space between the In and out point so that I can then delete it. I edited on final cut pro and I had custom key board settings where I would hit 1 for in point 3 for out point 2 to select between