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

Similar Messages

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

  • 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

  • Table OF user defined type in c#

    Hello
    I am running C# using Oracle (PL/SQL, provider ODP.NET
    11.1.0.6.20) and I have a procedure which at the moment returns a table of
    records. The code below demonstrates this.
    TYPE R_OutData_tab IS RECORD ( ... );
    TYPE OutData_tab IS TABLE OF R_OutData_tab INDEX BY BINARY_INTEGER;
    PROCEDURE PROPERTY_GET (tOutData OUT <packagename>.OutData_tab);
    Since .NET doesn't support Oracle records I'm looking into rewriting the
    procedure so that it returns a table of a user defined type instead. The
    code below demonstrates this.
    create type person_type as object (name varchar2(30), address varchar2(60),
    age varchar2(3));
    TYPE person_table IS TABLE OF odp_obj1_sample_person_type;
    PROCEDURE PERSONS_GET(out_persons OUT person_table);
    I know how to handle a single user-defined type in .NET returned from a
    Oralce procedure but what I need to do now is to receive a or pass table of a user
    defined type using procedure. Is this supported in .NET?

    Dear ,
    I have posted a similar kind of reply in one of the thread  which may help u defining the User Defined Tabel /Filed .Just check this Out :
    For cm25/CM21 : Assuming that you have all the other set up for Capacity Requirement in place , please note the belwo steps for layout design for CM25 OR cm21 or cm22( all you will be used same overall profile )
    1.Make sure that you have proper Overall profile defined in OPD0-Define Overall profile .Here u will define Time Profile , Startegy prfoile . Lay out Profile etc .
    2.To paint your layout your soultion is to Goto -CY38-Pop down the menu -Select the Lay out Key which have been used as lay out -Goto Change Mode (Pencil symbol)-Now you will find the fields are high ligheted as per CM25 dipaly in a sequnce -You can un chekcde the Filed like Operation , Operation text , Setup what ever you do not want to show in Order Pool and Hit SAVE butotn and come back .
    CM25 --> Settings --> Display Profiles --> Planning tab.profile --> I01 --> Layout ID ( Example : 'SAPSFCLA05') which is Main Capacity Lay out id .
    If you goto CY38-Pop down the menu -You will find Main Capcitity Lay out Id : Example SAPSFCAS01 -Enter this lay out and chenage accordingly as I have explained in above
    Once you save this , then go back to CM25 and execute with coupe of work centres to check how is the order pool looks now .
    Refer this threade for Layout Id and option which u may need for CM25 front end
    Exception messages in CM21 or CM25
    I hope this should work
    Regards

  • Issue with xsd Data type mapping for collection of user defined data type

    Hi,
    I am facing a issue with wsdl for xsd mapping for collection of user defined data type.
    Here is the code snippet.
    sample.java
    @WebMethod
    public QueryPageOutput AccountQue(QueryPageInput qpInput)
    public class QueryPageInput implements Serializable, Cloneable
    protected Account_IO fMessage = null;
    public class QueryPageOutput implements Serializable, Cloneable
    protected Account_IO fMessage = null;
    public class Account_IO implements Serializable, Cloneable {
    protected ArrayList <AccountIC> fintObjInst = null;
    public ArrayList<AccountIC>getfintObjInst()
    return (ArrayList<AccountIC>)fintObjInst.clone();
    public void setfintObjInst(AccountIC val)
    fintObjInst = new ArrayList<AccountIC>();
    fintObjInst.add(val);
    Public class AccountIC
    protected String Name;
    protected String Desc;
    public String getName()
    return Name;
    public void setName(String name)
    Name = name;
    For the sample.java code, the wsdl generated is as below:
    <?xml version="1.0" encoding="UTF-8" ?>
    <wsdl:definitions
    name="SimpleService"
    targetNamespace="http://example.org"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://example.org"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    >
    <wsdl:types>
    <xs:schema version="1.0" targetNamespace="http://examples.org" xmlns:ns1="http://example.org/types"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:import namespace="http://example.org/types"/>
    <xs:element name="AccountWSService" type="ns1:accountEMRIO"/>
    </xs:schema>
    <xs:schema version="1.0" targetNamespace="http://example.org/types" xmlns:ns1="http://examples.org"
    xmlns:tns="http://example.org/types" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:import namespace="http://examples.org"/>
    <xs:complexType name="queryPageOutput">
    <xs:sequence>
    <xs:element name="fSiebelMessage" type="tns:accountEMRIO" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="accountEMRIO">
    <xs:sequence>
    <xs:element name="fIntObjectFormat" type="xs:string" minOccurs="0"/>
    <xs:element name="fMessageType" type="xs:string" minOccurs="0"/>
    <xs:element name="fMessageId" type="xs:string" minOccurs="0"/>
    <xs:element name="fIntObjectName" type="xs:string" minOccurs="0"/>
    <xs:element name="fOutputIntObjectName" type="xs:string" minOccurs="0"/>
    <xs:element name="fintObjInst" type="xs:anyType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="queryPageInput">
    <xs:sequence>
    <xs:element name="fPageSize" type="xs:string" minOccurs="0"/>
    <xs:element name="fSiebelMessage" type="tns:accountEMRIO" minOccurs="0"/>
    <xs:element name="fStartRowNum" type="xs:string" minOccurs="0"/>
    <xs:element name="fViewMode" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.org" xmlns:ns1="http://example.org/types">
    <import namespace="http://example.org/types"/>
    <xsd:complexType name="AccountQue">
    <xsd:sequence>
    <xsd:element name="arg0" type="ns1:queryPageInput"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="AccountQue" type="tns:AccountQue"/>
    <xsd:complexType name="AccountQueResponse">
    <xsd:sequence>
    <xsd:element name="return" type="ns1:queryPageOutput"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="AccountQueResponse" type="tns:AccountQueResponse"/>
    </schema>
    </wsdl:types>
    <wsdl:message name="AccountQueInput">
    <wsdl:part name="parameters" element="tns:AccountQue"/>
    </wsdl:message>
    <wsdl:message name="AccountQueOutput">
    <wsdl:part name="parameters" element="tns:AccountQueResponse"/>
    </wsdl:message>
    <wsdl:portType name="SimpleService">
    <wsdl:operation name="AccountQue">
    <wsdl:input message="tns:AccountQueInput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
    ns1:Action=""/>
    <wsdl:output message="tns:AccountQueOutput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
    ns1:Action=""/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SimpleServiceSoapHttp" type="tns:SimpleService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="AccountQue">
    <soap:operation soapAction=""/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SimpleService">
    <wsdl:port name="SimpleServicePort" binding="tns:SimpleServiceSoapHttp">
    <soap:address location="http://localhost:7101/WS-Project1-context-root/SimpleServicePort"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>
    In the above wsdl the collection of fintObjInst if of type xs:anytype. From the wsdl, I do not see the xsd mapping for AccountIC which includes Name and Desc. Due to which, when invoking the web service from a different client like c#(by creating proxy business service), I am unable to set the parameters for AccountIC. I am using JAX-WS stack and WLS 10.3. I have already looked at blog http://weblogs.java.net/blog/kohlert/archive/2006/10/jaxws_and_type.html but unable to solve this issue. However, at run time using a tool like SoapUI, when this wsdl is imported, I am able to see all the params related to AccountIC class.
    Can some one help me with this.
    Thanks,
    Sudha.

    Did you try adding the the XmlSeeAlso annotation to the webservice
    @XmlSeeAlso({<package.name>.AccountIC.class})
    This will add the schema for the data type (AccountIC) to the WSDL.
    Hope this helps.
    -Ajay

  • How to create a user defined type base on existing table

    Hi Everyone,
    Are there any way to create a user defined type base on existing table us as :
    CREATE OR REPLACE Type MyTable Is Table Of PART%ROWTYPE;
    where Part is a table.
    Regards,
    JDang

    Hi JDAng,
    Can't be done. %ROWTYPE is a PL/SQL construct, and as such cannot be used in SQL.
    Regards
    Peter

  • 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

  • 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);

  • Confused: Returning Simple User Defined Type (non-built-in)

    Hi, hope you can straighten out a confused newbie! This is probably laughingly simple if you know how...
    I just want my weblogic workshop web service to return an ordinary record-style object to my static client. I'm not sure what to do, I've already tried a few approaches...
    If I use two services deployed on Weblogic Server everything works great. Weblogic server must handle the seriali/deseriali - zation for you.
    So I tried to use the java proxy downloaded from the test page, but it doesn't contain all the classes needed.
    I read the Weblogic help files which said to use autotype, which compiles but gives class cast exceptions running. I tried both automatic and manual with same error. Trying to import to Workshop gave me a "no handler defined error".
    And I bought a book from Amazon about J2EE and Weblogic but it does not include a section on user defined types!
    Am I supposed to use XMLBeans or something??? Please help!
    Regards, Ry.

    > but the requirement is not allowing me to do either with ref cursor or with
    returning clause. Because, in .Net development area , we are restricted for
    using Returning clause.
    The following is a Bad Idea (tm) where PL/SQL is used to "return data" to the caller, be that via PL/SQL record types or collection types..Net   ---[calls]-------> PL/SQL
    PL/SQL ---[calls]-------> SQL
    PL/SQL <--[data]--------- SQL
    PL/SQL [buffers] data
    .Net   <--[buffer data]-- PL/SQLWhy?
    Because PL/SQL is a poor choice for a buffer as the db cache buffer used by the SQL engine is a very advance and sophisticated cache and core to the Oracle RDBMS.
    Ain't no way you can do that better in PL/SQL than SQL.
    What is the typical client-server approach in Oracle?.Net   ---[calls]-------> PL/SQL
    PL/SQL [constructs ref cursor]
    .Net   <--[ref cursor]-- PL/SQL
    .Net   --[fetches]----> SQL [using ref cursor]A ref cursor is a pointer the "compiled and executable SQL program" in Oracle that PL/SQL constructed for .Net in this case. Each FETCH call using the ref cursor pointer, executes the cursor "program" and returns the next row (or set of rows when using bulk processing) to the client.

  • 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

  • User-Defined Type does not display values in Table Data grid

    I have a User defined Type that is a collection of one character VARCHAR2 values. In the Table Data grid it does not display the character values. I know on all our other Oracle development applications these values display. Is this a bug or is there a snippet to display these values?

    Version: 1.0.0.15
    DB: 10.2.0
    Workstation OS: Windows XP

  • Accessing User Defined Types

    We have recently updated our libraries to the latest version (2.102.2.20) - and have lost access to the critical objects and methods that were accessing our User Defined Types on Oracle.
    In particular, this code:
    OracleUdtDescriptor descriptor = OracleUdtDescriptor.GetOracleUdtDescriptor((OracleConnection)conn, "MY_USER.MYTYPE");
    OracleArray items = new OracleArray(descriptor);
    foreach (string s in testArrayItems)
    items.Append(s);
    IDbDataParameter itemsParam = cmd.OracleParameters.Add("items", OracleDbType.VArray, items, ParameterDirection.Input);
    simply doesn't work anymore. The 'OracleUdtDescriptor' and 'OracleArray' references no longer exist. This has brought all development on a critical application to a halt. (Doesn't it always.)
    How can I get the same functionality using the new version (2.102.2.20) of the Oracle.DataAccess library?

    Hi,
    Here's what I was referring to... say you wanted to execute the same procedure from PLSQL via an anonymous block. Execute the same anonymous block via ODP.NET.
    Here's a simple dumb example that passes an object type to a stored procedure, hope it helps. Hokey example, but hopefully points out what I was trying to say.
    Greg
    SQL
    ========
    create or replace type person_typ as object (name varchar2(50), age number(4))
    create table person_tab(col1 number, col2 person_typ);
    create or replace procedure insert_person_proc(v1 in number, v2 in person_typ) as
    begin
    insert into person_tab values(v1,v2);
    end;
    You could execute that via PLSQL as follows
    =================================
    declare
      myperson person_typ;
    begin
      myperson := person_typ('melody',5);
      insert_person_proc(1,myperson);
    end;
    /And do the same thing via ODP.NET
    =============================
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    class Program
        static void Main(string[] args)
            using (OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger"))
                con.Open();
                using (OracleCommand cmd = new OracleCommand("",con))
                    string strsql = "declare " +
                                    "myperson person_typ; " +
                                    "begin " +
                                    "myperson := person_typ(:1,:2); " +
                                    "insert_person(:3,myperson); " +
                                    "end; ";
                    cmd.CommandText = strsql;
                    cmd.Parameters.Add(new OracleParameter("", "Melody"));
                    cmd.Parameters.Add(new OracleParameter("", 5));
                    cmd.Parameters.Add(new OracleParameter("", 1));
                    cmd.ExecuteNonQuery();
    }

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

  • 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

  • Add column to user defined type based on existing table

    Hello guys,
    I am trying to compile my function which returns a user defined type based on existing table. Throughout the initializing process though my query returns one additional column - SCORE(1). Here is my package:
    create or replace
    PACKAGE STAFF_AGENCY_PKG AS
    TYPE TYPE_SEEKER_TABLE IS TABLE OF TOSS.SEEKER%ROWTYPE;
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED;
    END STAFF_AGENCY_PKG;
    create or replace
    PACKAGE BODY STAFF_AGENCY_PKG
    AS
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED
    IS
    R_TBL TYPE_SEEKER_TABLE; -- to be returned
    BEGIN
    FOR R IN(
    SELECT Seeker.SEEKER_ID,
    Seeker.FIRSTNAME,
    Seeker.LASTNAME,
    Seeker.NATIONALITY,
    Seeker.ISELIGIBLE,
    Seeker.BIRTHDATE,
    Seeker.ISRECIEVEEMAILS,
    Seeker.HIGHESTDEGREE,
    Seeker.ETHNICITY,
    Seeker.GENDER,
    Seeker.ISDISABILITY,
    Seeker.DISABILITY,
    Seeker.CV,
    Seeker.PASSWORD,
    Seeker.PREFFERED_CITY,
    SEEKER.EMAIL,
    SEEKER.JOB_PREFERENCES_ID,
    SCORE(1)
    FROM SEEKER Seeker
    WHERE CONTAINS(CV, '<query>
    <textquery lang="ENGLISH" grammar="context">' ||
    GET_RELATED_CATEGORIES(IN_KEYWORD) ||
    '</textquery>
    <score datatype="INTEGER"/>
    </query>', 1) > 0
    LOOP
    PIPE ROW(R); --Error(38,10): PLS-00382: expression is of wrong type
    END LOOP;
    RETURN;
    END GET_SEEKERS;
    END STAFF_AGENCY_PKG;
    How do I need to amend my user type in order to suffice?
    Oracle Release 11.2.0.1.0
    Many thanks in advance!

    >
    How do I need to amend my user type in order to suffice?
    >
    You will need to create two new TYPEs. One that has all of the columns of the TOSS.SEEKER table and the new SCORE column and then a TYPE that is a table of the first type.
    See the Example 12-22 Using a Pipelined Table Function For a Transformation in the PL/SQl language reference
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm#i53120
    Here is the first part
    -- Define the ref cursor types and function
    CREATE OR REPLACE PACKAGE refcur_pkg IS
      TYPE refcur_t IS REF CURSOR RETURN employees%ROWTYPE;
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;
    FUNCTION f_trans(p refcur_t)
          RETURN outrecset PIPELINED;
    END refcur_pkg;
    CREATE OR REPLACE PACKAGE BODY refcur_pkg IS
      FUNCTION f_trans(p refcur_t)
       RETURN outrecset PIPELINED IS
        out_rec outrec_typ;
        in_rec  p%ROWTYPE;
      BEGINModify
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;to include all of the columns you need. Unfortunately you will have to manually list all of the columns of the TOSS.SEEKER table. If you expect to need this same structure in other places you should create them as SQL types instead of PL/SQL types.
    This example should be enough to show you how to change your code to do something similar.

Maybe you are looking for

  • Horizontal scroll bar in tabular form with columns freeze

    Hi All, I have a requirement where i have to create a tabular form in which the first three columns should be in freeze mode and it should have a horizontal scroll bar. with the help of Google i found an example [http://apex.oracle.com/pls/otn/f?p=26

  • HS : Connecting from 9.2.0.8 database on AIX to  MS SQL 2008R2

    Hello , We have a requirement to connect from 9.2.0.8 database on AIX to MS SQL 2008R2 . Source : Oracle : 9.2.0.8 (64 bit) OS : AIX - 4.3.3.0/5.3.0.0 (64-bit) Target : MS SQL : 2008R2 OS : Windows 2008 (64-bit) 1] Can we use - Database Gateway for S

  • Does album "match" if it contains a typo??

    I haven't joined Match yet, but am seriously thinking about it. My biggest question right now has to do with naming artists, albums, songs, etc. Does the information in my iTunes Library have to match up exactly to the information in the iTunes Store

  • Checkbox in midp

    does anyone know how I can implement a checkbox in midp? Is there anything tht I can do to simulate a check box or radio button in midp? I would appreciate any comments :) cheers cleoppatra

  • DATA BASE AND PROGRAMMING

    Dear All, i am a novice to Oracle. i saw many oracle versions and under product list also. can you tell me which one is useful for Oracle Programming. i have literature of Oracle9i . i have gone through this . it is for managing relational database.