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.

Similar Messages

  • Dose oracle.sql.ArrayDescriptor support the user defined type in package?

    Hi folks:
    I get a obstacle in calling stored procedure by using JDBC driver (ojdbc14.jar).
    I have the following code:
    create or replace package xxx AS
    type var_table is table of varchar2(50);
    procedure(parameter in var_table);
    end xxx;
    When I use the jdbc driver try to create a type for
    oracle.sql.ArrayDescriptor arrayDes = oracle.sql.ArrayDescriptor.createDescriptor( "var_table ",connection);
    The SQLException is thrown out like those:
    Invalid name pattern:user_schema. var_table
    So, my question is : Dose oracle.sql.ArrayDescriptor not support the user defined type in package? And I also tried to define such type by using sql "create xxxx" outside of package, then there is no SQLException.
    Hopefully for your response and suggestion.Thanks...

    To my knowledge, the Oracle JDBC driver does not support using the ArrayDescriptor for array data types (varray or nested table) that are defined inside of a package. The same is true for StructDescriptor as well. If you want to use array and object data types, you must define them outside of a package. Then you'll be able to use the descriptors in your JDBC programs.

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

  • Querying user-defined types

    I have a table in which one of the columns is a user-defined datatype:
    SQL> describe my_table
    USER_DATA    MYTYPEThe type "MYTYPE" is a simple object that contains one field: a CLOB called MESSAGE:
    SQL> describe mytype
    Name       Null?    Type
    MESSAGE          CLOBWhen I do a "select * ..." from this table, the column USER_DATA is displayed as "MYTYPE(oracle.sql.CLOB@898c2d)"
    I know that for CLOB and BLOB fields, SQL Developer will let me double click the value and view the contents. But for a user-defined type like this that contains a field, I cannot browse into the data members of the type. I find myself wanting to do something like a "select user_data.message from my_table", but this is not valid syntax. Is there a way to query a specific data member of this user-defined type with the rest of the columns in the table so that I can be shown the CLOB member instead of a representation of the object? If not, is there a way to configure SQL Developer to allow me to browse the data members of user-defined types? TOAD has a feature like this but I would like to use SQL Developer exclusively and this is one table I must work with regularly.

    Just to back up a previous post:
    sqldeveloper 1.5.5.59.69 against 10.2 (Express Edition)
    desc r2
    input:
    select r.message from r2; --fails
    select r2.r.message from r2; --fails
    select this.r.message from r2 this; --succeeds
    output:
    desc r2
    Name Null Type
    R REALLY_CLOB()
    Error starting at line 1 in command:
    select r.message from r2
    Error at Command Line:1 Column:7
    Error report:
    SQL Error: ORA-00904: "R"."MESSAGE": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:   
    *Action:
    Error starting at line 2 in command:
    select r2.r.message from r2
    Error at Command Line:2 Column:7
    Error report:
    SQL Error: ORA-00904: "R2"."R"."MESSAGE": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:   
    *Action:
    R.MESSAGE
    (CLOB)
    (CLOB)
    (CLOB) start of clob
    3 rows selected

  • Create user defined type under SQL type

    Hello guys,
    I have a table PART_NEEDED and a table function which returns table of PART_NEEDED%ROWTYPE. This works fine but if I try to create new user defined type with with the same attributes as PART_NEEDED and pipe the rows into table of that type I am getting an inconsistency of types error - Error(30,16): PLS-00382: expression is of wrong type.
    Please refer to the script below. I appreciate any help!
    CREATE TABLE "TOSS"."PART_NEEDED"
    "PART_NEEDED_ID" NUMBER NOT NULL ENABLE,
    "TYPE_OF_PART_NEEDS_ID" NUMBER,
    "TYPE_OF_PART_IS_NEEDED_ID" NUMBER,
    "AMOUNT" NUMBER
    SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
    INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT
    TABLESPACE "USERS" ;
    CREATE OR REPLACE TYPE "TYPE_PART_NEEDED" AS OBJECT
    ID NUMBER,
    PART_ID NUMBER,
    SUB_PART_ID NUMBER,
    AMOUNT NUMBER
    create or replace package KOLEV_ADMIN_PKG as
    TYPE TYPE_PART_NEEDED_TBL IS TABLE OF TOSS.TYPE_PART_NEEDED; -- if the type here is PART_NEEDED%ROWTYPE it works perfectly fine
    FUNCTION GET_SUBPARTS (IN_PART_ID IN NUMBER)
    RETURN TYPE_PART_NEEDED_TBL PIPELINED;
    end;
    CREATE OR REPLACE PACKAGE BODY "KOLEV_ADMIN_PKG" AS
    FUNCTION GET_SUBPARTS (IN_PART_ID IN NUMBER)
    RETURN TYPE_PART_NEEDED_TBL PIPELINED
    IS
    R_TBL TYPE_PART_NEEDED_TBL; -- To be returned
    BEGIN
    FOR R IN (
    WITH
    SUBPARTS(ID, PART_ID, SUBPART_ID, AMOUNT) AS
    SELECT PART_NEEDED_ID, TYPE_OF_PART_NEEDS_ID, TYPE_OF_PART_IS_NEEDED_ID, AMOUNT
    FROM PART_NEEDED
    WHERE TYPE_OF_PART_NEEDS_ID = IN_PART_ID
    UNION ALL
    SELECT PN.PART_NEEDED_ID, PN.TYPE_OF_PART_NEEDS_ID, PN.TYPE_OF_PART_IS_NEEDED_ID, PN.AMOUNT
    FROM SUBPARTS SP, PART_NEEDED PN
    WHERE PN.TYPE_OF_PART_NEEDS_ID = SP.SUBPART_ID
    SELECT SP.ID, SP.PART_ID, SP.SUBPART_ID, SP.AMOUNT
    FROM SUBPARTS SP
    ORDER BY PART_ID
    LOOP
    PIPE ROW(R); -- Error(30,16): PLS-00382: expression is of wrong type
    END LOOP;
    RETURN;
    END GET_SUBPARTS;
    END "KOLEV_ADMIN_PKG";
    INSERT INTO "TOSS"."PART_NEEDED" (PART_NEEDED_ID, TYPE_OF_PART_NEEDS_ID, TYPE_OF_PART_IS_NEEDED_ID, AMOUNT) VALUES ('4', '2', '3', '2')
    INSERT INTO "TOSS"."PART_NEEDED" (PART_NEEDED_ID, TYPE_OF_PART_NEEDS_ID, TYPE_OF_PART_IS_NEEDED_ID, AMOUNT) VALUES ('5', '3', '1', '2')
    INSERT INTO "TOSS"."PART_NEEDED" (PART_NEEDED_ID, TYPE_OF_PART_NEEDS_ID, TYPE_OF_PART_IS_NEEDED_ID, AMOUNT) VALUES ('3', '2', '1', '4')
    INSERT INTO "TOSS"."PART_NEEDED" (PART_NEEDED_ID, TYPE_OF_PART_NEEDS_ID, TYPE_OF_PART_IS_NEEDED_ID, AMOUNT) VALUES ('17', '3', '4', '1')
    Database Release 11.2.0.1.0
    I want this functionality because I need to make some joins and add descriptions for each part. Now this table PART_NEEDED contains only IDs - many to many.
    Regards!
    Edited by: Todor Kolev on Mar 3, 2012 12:47 PM

    CREATE OR REPLACE
      PACKAGE BODY KOLEV_ADMIN_PKG
        AS
          FUNCTION GET_SUBPARTS (IN_PART_ID IN NUMBER)
            RETURN TYPE_PART_NEEDED_TBL PIPELINED
            IS
            BEGIN
                FOR R IN (
                          WITH SUBPARTS(ID, PART_ID, SUBPART_ID, AMOUNT)
                            AS (
                                 SELECT  PART_NEEDED_ID,
                                         TYPE_OF_PART_NEEDS_ID,
                                         TYPE_OF_PART_IS_NEEDED_ID,
                                         AMOUNT
                                   FROM  PART_NEEDED
                                   WHERE TYPE_OF_PART_NEEDS_ID = IN_PART_ID
                                UNION ALL
                                 SELECT  PN.PART_NEEDED_ID,
                                         PN.TYPE_OF_PART_NEEDS_ID,
                                         PN.TYPE_OF_PART_IS_NEEDED_ID,
                                         PN.AMOUNT
                                   FROM  SUBPARTS SP,
                                         PART_NEEDED PN
                                   WHERE PN.TYPE_OF_PART_NEEDS_ID = SP.SUBPART_ID
                          SELECT  TYPE_PART_NEEDED(
                                                   SP.ID,
                                                   SP.PART_ID,
                                                   SP.SUBPART_ID,
                                                   SP.AMOUNT
                                                  ) O
                            FROM  SUBPARTS SP
                            ORDER BY PART_ID
                         ) LOOP
                  PIPE ROW(R.O);
                END LOOP;
                RETURN;
          END GET_SUBPARTS;
    END KOLEV_ADMIN_PKG;
    /SY.

  • Create user-defined type

    Can I create a user-defined type with a range between 1 to 10.
    e.g. insert into table values (udt(11)) will prompt an error

    You will need to either provide different names for the
    constraints or let the system provide the names, like this:
    SET     ECHO OFF
    SET     FEEDBACK OFF
    SET     PAGESIZE 0
    SPOOL   add_constraints.sql
    SELECT 'ALTER TABLE ' || table_name
       || ' ADD CHECK (udt BETWEEN 1 AND 10);'
    FROM    user_tab_columns
    WHERE   column_name = 'UDT';
    SPOOL   OFF
    SET     PAGESIZE 24
    SET     FEEDBACK ON
    SET     ECHO ON
    START   add_constraints

  • 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

  • Issue in passing Oracle User Defined Types to PL SQL from Websphere Applica

    HI,
    I am facing an issue when trying to pass Oracle collection object(User Defined Types) from Java to PL SQL. The issue happens inside J2EE application which is running inside Websphere Application Server 6.x. My database is Oracle 10g and i am using ojdbc1.4.jar as thin driver.
    The issue is that when i pass the Oracle Object from java side, the attribute values of the collection objects at the Oracle PL SQL side is coming as empty. I have tried the same java code in a standalone application and it works fine. The issue happens only when the application is running inside WAS.
    Anybody has any idea how to pass Oracle User Defined Types from WAS 6.x server to Oracle PL SQL?

    Andy Bowes wrote:
    Hi
    I am using WebLogic 8.14 & Oracle 9i with thin JDBC driver.
    Our application needs to perform the same DB operation for every item in a Java Collection. I cannot acheive the required performance using the standard Prepare & Execute loop and so I am looking to push the whole collection to Oracle in a single invocation of a Stored Procedure and then loop on the database.
    Summary of Approach:
    In the Oracle database, we have defined a Object Type :
    CREATE OR REPLACE
    TYPE MYTYPE AS OBJECT
    TxnId VARCHAR2(40),
    Target VARCHAR2(20),
    Source VARCHAR2(20),
    Param1 VARCHAR2(2048),
    Param2 VARCHAR2(2048),
    Param3 VARCHAR2(2048),
    Param4 VARCHAR2(2048),
    Param5 VARCHAR2(2048),
    and we have defined a collection of these as:
    CREATE OR REPLACE
    TYPE MYTYPE_COLLECTION AS VARRAY (100) OF MYTYPE
    There is a stored procedure which takes one of these collections as an input parameter and I need to invoke these from within my code.
    I am having major problems when I attempt to get the ArrayDescriptor etc to allow me to create an Array to pass to the stored procedure. I think this is because the underlying Oracle connection is wrapped by WebLogic.
    Has anyone managed to pass an array to an Oracle Stored procedure on a pooled DB connection?
    Thanks
    AndyHi. Here's what I suggest: First please get the JDBC you want to work in a
    small standalone program that uses the Oracle thin driver directly. Once
    that works, show me the JDBC code, and I will see what translation if
    any is needed to make it work with WLS. Will your code be running in
    WebLogic, or in an external client talking to WebLogic?
    Also, have you tried the executeBatch() methods to see if you can
    get the performance you want via batches?
    Joe

  • 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

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

  • Access result set in user define type of table

    here is the situation. I have a stored procedure that dequeues messages of a AQ and passes them as an OUT parameter in a collection of a user defined type. The same type used to define the queues. The java code executes properly but seems like we don't/can't access the result set. We don't receive any erros but don't know how to access the results. I've included relevant parts of the problem.
    I know this should be doable but........Can someone please tell us what we are doing wrong....thanks in advance.
    -----create object type
    create type evt_ot as object(
    table_name varchar(40),
    table_data varchar(4000));
    ---create table of object types.
    create type msg_evt_table is table of evt_ot;
    ----create queue table with object type
    begin
    DBMS_AQADM.CREATE_QUEUE_TABLE (
    Queue_table => 'etlload.aq_qtt_text',
    Queue_payload_type => 'etlload.evt_ot');
    end;
    ---create queues.
    begin
    DBMS_AQADM.CREATE_QUEUE (
    Queue_name => 'etlload.aq_text_que',
    Queue_table => 'etlload.aq_qtt_text');
    end;
    Rem
    Rem Starting the queues and enable both enqueue and dequeue
    Rem
    EXECUTE DBMS_AQADM.START_QUEUE (Queue_name => 'etlload.aq_text_que');
    ----create procedure to dequeue an array and pass it OUT using msg_evt_table ---type collection.
    create or replace procedure test_aq_q (
    i_array_size in number ,
    o_array_size out number ,
    text1 out msg_evt_table) is
    begin
    DECLARE
    message_properties_array dbms_aq.message_properties_array_t :=
    dbms_aq.message_properties_array_t();
    msgid_array dbms_aq.msgid_array_t;
    dequeue_options dbms_aq.dequeue_options_t;
    message etlload.msg_evt_table;
    id pls_integer := 0;
    retval pls_integer := 0;
    total_retval pls_integer := 0;
    ctr number :=0;
    havedata boolean :=true;
    java_exp exception;
    no_messages exception;
    pragma EXCEPTION_INIT (java_exp, -24197);
    pragma exception_init (no_messages, -25228);
    BEGIN
    DBMS_OUTPUT.ENABLE (20000);
    dequeue_options.wait :=0;
    dequeue_options.correlation := 'event' ;
    id := i_array_size;
    -- Dequeue this message from AQ queue using DBMS_AQ package
    begin
    retval := dbms_aq.dequeue_array(
    queue_name => 'etlload.aq_text_que',
    dequeue_options => dequeue_options,
    array_size => id,
    message_properties_array => message_properties_array,
    payload_array => message,
    msgid_array => msgid_array);
    text1 := message;
    o_array_size := retval;
    EXCEPTION
    WHEN java_exp THEN
    dbms_output.put_line('exception information:');
    WHEN no_messages THEN
    havedata := false;
    o_array_size := 0;
    end;
    end;
    END;
    ----below is the java code....
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Struct;
    import oracle.jdbc.driver.OracleCallableStatement;
    import oracle.jdbc.driver.OracleTypes;
    public class TestOracleArray {
         private final String SQL = "{call etlload.test_aq_q(?,?,?)}";//array size, var name for return value, MessageEventTable
         private final String driverClass = "oracle.jdbc.driver.OracleDriver";
         private final String serverName = "OurServerName";
         private final String port = "1500";
         private final String sid = "OurSid";
         private final String userId = "OurUser";
         private final String pwd = "OurPwd";
         Connection conn = null;
         public static void main(String[] args){
              TestOracleArray toa = new TestOracleArray();
              try {
                   toa.go();
              } catch (InstantiationException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IllegalAccessException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (ClassNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         private void go() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{
              Class.forName(driverClass).newInstance();
              String url = "jdbc:oracle:thin:@"+serverName+":"+port+":"+sid;
              conn = DriverManager.getConnection(url,userId,pwd);
              OracleCallableStatement stmt = (OracleCallableStatement)conn.prepareCall(SQL);
              //set 1 input
              stmt.setInt(1, 50);
              //register out 1
              stmt.registerOutParameter(2, OracleTypes.NUMERIC);
              //register out 2
              stmt.registerOutParameter(3, OracleTypes.ARRAY, "MSG_EVT_TABLE");
              * This code returns a non-null ResultSet but there is no data in the ResultSet
              * ResultSet rs = stmt.executeQuery();
              * rs.close();
              * Tried all sorts of combinations of getXXXX(1);
              * All return the same error Message: Invalid column index
              * So it appears that the execute statment returns no data.
              stmt.execute();
              Struct myObject = (Struct)stmt.getObject(1);
              stmt.close();
              conn.close();
    }

    Hi,
    Sorry but I'd refer you to the following sections (and code samples/snippets) in my book:
    Mapping User-Defined Object Types (AD) to oracle.sql.STRUCT in section 3.3, shows how to pass user defined types as IN, OUT,IN/OUT
    JMS over Streams/AQ in the Database: shows how to consume AQ
    message paylod in section 4.2.4
    CorporateOnine, in section 17.2, show how to exchanges user defined type objects b/w AQ and JMS
    All these will hopefully help you achieve what you are trying to do.
    Kuassi

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

  • How to convert Collection to user defined type in db

    Hello All,
    I am using Apex 4.1.0.00.32 and Oracle 11g.
    I have page process to store the user selected rows (keys) in a collection as follows:
    declare
       temp varchar2(4000);
       vrow number;
       begin
       apex_collection.CREATE_OR_TRUNCATE_COLLECTION('SELECTED_PERSONS');
          IF (apex_application.g_f32.COUNT > 0) THEN
               FOR ii IN 1 .. htmldb_application.g_f32.COUNT
               LOOP
                    vrow := apex_application.g_f32(ii);
                   APEX_COLLECTION.ADD_MEMBER('SELECTED_PERSONS', apex_application.g_f30(vrow));
              END LOOP;
           END IF;
    end;I need to call a database function which takes an user defined type VC_ARRAY_1 defined as:
    create or replace TYPE  "VC_ARRAY_1"  AS TABLE OF VARCHAR2(4000) How do I convert the collection to VC_ARRAY_1, so that I can call the db function?
    Thanks,
    Rose

    Hi Joel,
    Yes, the collection contains the person_ids. But, I am selecting from a function which returns a pipelined table. In Oracle Database, few user defined types and functions are defined as given below:
    create or replace TYPE  "VC_ARRAY_1"   as table of varchar2(4000)
    create or replace FUNCTION   "GET_ARRAY" ( p_array  IN   varchar2,  p_delimiter   IN   varchar2  default ':')  return  VC_ARRAY_1 PIPELINED
    create or replace TYPE   "AFFECTED_INDIVIDUAL"  as object("PERSONKEY" VARCHAR2(4000),  "FIRST_NAME" VARCHAR2(4000), "LAST_NAME" VARCHAR2(4000)… more variables)
    create or replace TYPE  "AFF_IND_TAB"  as table of  "AFFECTED_INDIVIDUAL"
    create or replace FUNCTION  GET_AFF_INDIVIDUALS(personKeys IN VC_ARRAY_1) return  AFF_IND_TAB PIPELINEDThe function GET_AFF_INDIVIDUALS uses several tables and returns pipelined table. In Apex, I have a SQL query that feeds the Report query.
    select *  from table (get_aff_individuals(get_array(:F_SELECTED_PERSONS, ',')))The application item F_SELECTED_PERSONS is a varchar2 that contains comma separated person ids. I want to replace the application item with Apex collection. Initially, I thought that I can convert the apex collection to an array of vc_array_1.
    Thanks for your time and help.
    Rose

  • JPub Error User-defined type not found

    I just have found about Jpub could help me with my problem, so i try it, but when i try to publish a package it gives me this error:
    J2T-118, ERROR: User-defined type "ADMCAD.PKG_CONSULTA_BR_NOME.TAB_ELEITOR" was
    not found in the database
    This is the package:
    create or replace package admcad.pkg_consulta_br_nome as
    VT_NUM_INSCRICAO VARCHAR2(12);
    VT_COD_SIT_ELEITOR NUMBER(2);
    VT_NOM_ELEITOR VARCHAR2(70);
    VT_DAT_NASC NUMBER(8);
    VT_NUM_ZONA NUMBER(4);
    VT_SGL_UF VARCHAR2(2);
    -- tipo que sera retornado
    TYPE REC_TAB_ELEITOR IS RECORD (
              NUM_INSCRICAO VT_NUM_INSCRICAO%TYPE,
              NOM_ELEITOR     VT_NOM_ELEITOR%TYPE,
              NOM_PAI     VT_NOM_ELEITOR%TYPE,
              NOM_MAE     VT_NOM_ELEITOR%TYPE,
              DAT_NASC     VT_DAT_NASC%TYPE,
              DAT_DOMIC_MUNIC     DATE,
              COD_SIT_ELEITOR     VT_COD_SIT_ELEITOR%TYPE,
              SGL_UF     VT_SGL_UF%TYPE,
              NUM_ZONA     VT_NUM_ZONA%TYPE);
    TYPE tab_eleitor IS TABLE OF REC_TAB_ELEITOR INDEX BY BINARY_INTEGER;
    TYPE cursor_consulta IS REF CURSOR;
    SUBTYPE T_NUM_INSCRICAO is VT_NUM_INSCRICAO%TYPE;
    SUBTYPE T_COD_SIT_ELEITOR is VT_COD_SIT_ELEITOR%TYPE;
    SUBTYPE T_NOM_ELEITOR is VT_NOM_ELEITOR%TYPE;
    SUBTYPE T_NOM_PAI is VT_NOM_ELEITOR%TYPE;
    SUBTYPE T_NOM_MAE is VT_NOM_ELEITOR%TYPE;
    SUBTYPE T_DAT_DOMIC_MUNIC is date;
    SUBTYPE T_DAT_NASC is VT_DAT_NASC%TYPE;
    SUBTYPE T_SGL_UF is VT_SGL_UF%TYPE;
    SUBTYPE T_NUM_ZONA is VT_NUM_ZONA%TYPE;
    TYPE rec_consulta IS RECORD (
    num_inscricao T_NUM_INSCRICAO,
    cod_sit_eleitor T_COD_SIT_ELEITOR,
    nom_eleitor T_NOM_ELEITOR,
    nom_pai T_NOM_PAI,
    nom_mae T_NOM_MAE,
    dat_domic_munic T_DAT_DOMIC_MUNIC,
    dat_nasc T_DAT_NASC,
    sgl_uf          T_SGL_UF,
    num_zona          T_NUM_ZONA);
    procedure prc_consulta (     d01_cod_fon_nome in varchar2,
              d01_cod_fon_mae in varchar2,
              d01_dat_nasc in number,
                   d01_qtd_regs out number,
              vtab_eleitor in out tab_eleitor);
    end pkg_consulta_br_nome;
    This is the command line:
    jpub -user=XXX/XXX@there -sql=admcad.pkg_consulta_br_nome
    Am I wrong, or jpub was suppose to publish any type in the signature?
    Please help.
    Rafael Dittberner

    Rafael,
    I suggest you try asking in the Toplink discussion forum. You can find a link to it from this Web page:
    http://www.oracle.com/technology/products/ias/toplink/index.html
    Good Luck,
    Avi.

  • Data retrieval from columns having user defined type

    I was learning abstract types the other day.So I created an abstract type and a table.
    create type student_ty as object
    (name varchar2(20),roll number);
    create table result(
    student student_ty,
    total number);
    I have also inserted some data.But I am having some problems with the rretrieval of data.Suppose I want to select only the roll and name of the student as described in the studen type.So I used the follwing query:-
    select student.name from result;
    But its not working.But when i'm using something like this:-
    select r.total,r.student.name from result r;
    It is working perfectly.My question is that is it a rule that oracle enforces to use an alias whenever retrieving values from a user defined datatype?.Please help.
    Thanks in advance.

    Hi,
    Good observation. As you can see with your first query, the student is considered by oracle as a alias instead of a user-defined type column which is included in your result's table.
    >
    select student.name from result;
    >That is why in this case, you really need to use an alias or you can just use the complete table name like this:
    select result.student.name from resultBut, of course, it is not recommended, using alias is much appropriate.
    Cheers.

Maybe you are looking for

  • How to print our several Billing documents in one spool request?

    Hello all, I encountered a problem while printing billing document. Currently, we only can use VF02 to change billing document's condition type and print out Billing document. It's troublesome and waste a lot of time to change output condition type i

  • How to update Row Object in JSP Page? urgent!!!

    HI, I have a JSP Page and I have used jbo:DataSource and jbo:ApplicationModuleTags. Step 1: I have created a oracle.jbo.ViewObject view using view = ds.getRowSet().getViewObject(); and executed query using view.executeQuery() Step 2: I access the Row

  • Poor reception when watching downloaded TV shows

    Don't know if this is really the right place to post this, but, when I watch TV shows that I have downloaded from iTunes on my Mac, they are choppy, slow and pixilated. They kind of choke. Any settings I can change to make viewing a little easier on

  • No cross-device copying of music in v.11?

    The setting: 1) MBPro with OS 10.6.8 and iTunes 10.7 2) MBAir with OS 19.8.2 and iTunes 11 3) MacPro with OS 10.6.8 and iTunes 11 All Macs authorized in the store on the same account. All libraries set to home sharing. Trying to copy a song from (1)

  • How to publish Smart form of PDF in r/3 through WD

    Hi, We have a PDF smart form in the r/3.we want to call the PDF from WD View without using PDF interactive form. Could any one give me soln for this?? Thanks