PL/SQL add procedure with nested table - Duplicate Thread

Hi,
I am trying to do a procedure to input information for one order and another for 2 orders.
The information I have so far is as follows:
Drop table Orders cascade constraints;
Drop type item_type;
Drop type Item_nested;
Create or Replace Type item_type AS Object (
Cat_code Varchar2(6),
Amount_ord Number(3),
Cost Number(5,2) );
Create or Replace Type item_nested as table of item_type;
Create Table Orders (
Order_no Varchar2(8) constraint pkorder primary key,
Customer_name Varchar2(30),
AddressLine1 Varchar2(20),
AddressLine2 Varchar2(20),
AddressLine3 Varchar2(20),
Town Varchar2(20),
Postcode Varchar2(10),
Country Varchar2(20),
Order_items item_nested,
Order_date Date)
Nested Table Order_items
Store as nested_items return as locator;
This has so far worked but I have not managed the insert procedure.
I am using Oracle SQL*plus
Thanks
SG
Edited by: user10689875 on 11-Jan-2009 03:39

Duplicate thread ->
PL/SQL add procedure with nested table
Please remove it & marked it as duplicate.
Regards.
Satyaki De.

Similar Messages

  • PL/SQL add procedure with nested table

    Hi,
    I am trying to do a procedure to input information for one order and another for 2 orders.
    The information I have so far is as follows:
    Drop table Orders cascade constraints;
    Drop type item_type;
    Drop type Item_nested;
    Create or Replace Type item_type AS Object (
    Cat_code Varchar2(6),
    Amount_ord Number(3),
    Cost Number(5,2) );
    Create or Replace Type item_nested as table of item_type;
    Create Table Orders (
    Order_no Varchar2(8) constraint pkorder primary key,
    Customer_name Varchar2(30),
    AddressLine1 Varchar2(20),
    AddressLine2 Varchar2(20),
    AddressLine3 Varchar2(20),
    Town Varchar2(20),
    Postcode Varchar2(10),
    Country Varchar2(20),
    Order_items item_nested,
    Order_date Date)
    Nested Table Order_items
    Store as nested_items return as locator;
    This has so far worked but I have not managed the insert procedure.
    I am using Oracle SQL*plus
    Thanks
    SG

    What I think I need is something of the sort
    Create or replace procedure add_order (ordno in Varchar2, Cust_name in varchar2, add1 in varchar2,
    add2 in varchar2, add3 in Varchar2, Addtown in varchar2, Pstcde in Varchar2, addcountry in varchar2, ord_date in date)
    AS
    Begin
    DBMS_OUTPUT.PUT_LINE ('Insert attempted');
    Insert into Orders (Order_no,Customer_name, AddressLine1, AddressLine2, AddressLine3,
    Town, Postcode, Country, Order_Date)
    values (ordno, Cust_name,add1, add2, add3, Addtown, Pstcde, addcountry,
    ord_date);
    Commit;
    DBMS_OUTPUT.PUT_LINE ('Insert successful');
    Exception
    When Others then DBMS_OUTPUT.PUT_LINE ('ERROR');
    DBMS_OUTPUT.PUT_LINE ('Procedure failed');
    End;
    SG

  • Using FOR .. LOOP counter in handling of PL/SQL procedures with nest. table

    Hi all!
    I'm learning PL/SQL on Steve Bobrovsky's book (specified below sample is from it) and I've a question.
    In the procedure of specified below program used an integer variable currentElement to get reference to the row of nested table of %ROWTYPE datatype.
    Meanwhile, the program itself uses a common FOR .. LOOP counter i.
    DECLARE
    TYPE partsTable IS TABLE OF parts%ROWTYPE;
    tempParts partsTable := partsTable();
    CURSOR selectedParts IS
      SELECT * FROM parts ORDER BY id;
    currentPart selectedParts%ROWTYPE;
    currentElement INTEGER;
    PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
      BEGIN
       DBMS_OUTPUT.PUT_LINE(' ');
       DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
       currentElement := p_collection.FIRST;
       FOR i IN 1 .. p_collection.COUNT
       LOOP
        DBMS_OUTPUT.PUT('Element #' || currentElement || ' is ');
         IF tempParts(currentElement).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
         ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(currentElement).id || ' DESCRIPTION: ' || tempParts(currentElement).description);
         END IF;
        currentElement := p_collection.NEXT(currentElement);
       END LOOP;
    END printParts;
    BEGIN
    FOR currentPart IN selectedParts
    LOOP
      tempParts.EXTEND(2);
      tempParts(tempParts.LAST) := currentPart;
    END LOOP;
    printParts('Densely populated', tempParts);
    FOR i IN 1 .. tempParts.COUNT
    LOOP
      IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
      END IF;
    END LOOP;
    FOR i IN 1 .. 50
    LOOP
      DBMS_OUTPUT.PUT('-');
    END LOOP;
    printParts('Sparsely populated', tempParts);
    END;
    /When I've substituted an INTEGER global variable with such FOR .. LOOP counter, an APEX have returned an error "ORA-01403: no data found".
    DECLARE
    TYPE partsTable IS TABLE OF parts%ROWTYPE;
    tempParts partsTable := partsTable();
    CURSOR selectedParts IS
      SELECT * FROM parts ORDER BY id;
    currentPart selectedParts%ROWTYPE;
    PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
      BEGIN
       DBMS_OUTPUT.PUT_LINE(' ');
       DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
       FOR i IN 1 .. p_collection.COUNT
       LOOP
        DBMS_OUTPUT.PUT('Element is ');
         IF tempParts(i).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
         ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(i).id || ' DESCRIPTION: ' || tempParts(i).description);
         END IF;
       END LOOP;
    END printParts;
    BEGIN
    FOR currentPart IN selectedParts
    LOOP
      tempParts.EXTEND(2);
      tempParts(tempParts.LAST) := currentPart;
    END LOOP;
    printParts('Densely populated', tempParts);
    FOR i IN 1 .. tempParts.COUNT
    LOOP
      IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
      END IF;
    END LOOP;
    FOR i IN 1 .. 50
    LOOP
      DBMS_OUTPUT.PUT('-');
    END LOOP;
    printParts('Sparsely populated', tempParts);
    END;
    /When I've tried to handle this code in SQL*Plus, the following picture have appeared:
    Densely populated elements: 10
    Element is an empty element.
    Element is ID: 1 DESCRIPTION: Fax Machine
    Element is an empty element.
    Element is ID: 2 DESCRIPTION: Copy Machine
    Element is an empty element.
    Element is ID: 3 DESCRIPTION: Laptop PC
    Element is an empty element.
    Element is ID: 4 DESCRIPTION: Desktop PC
    Element is an empty element.
    Element is ID: 5 DESCRIPTION: Scanner
    Sparsely populated elements: 5
    DECLARE
    ERROR at line 1:                                 
    ORA-01403: no data found                         
    ORA-06512: at line 14                            
    ORA-06512: at line 35What's wrong in code(or what I have not understood)? Help please!

    942736 wrote:
    What's wrong in code(or what I have not understood)? Help please!First code. You have collection of 10 elements:
    1 - null
    2 - populated
    3 - null
    4 - populated
    5 - null
    6 - populated
    7 - null
    8 - populated
    9 - null
    10 - populated
    Then you delete null elements and have 5 element collection
    2 - populated
    4 - populated
    6 - populated
    8 - populated
    10 - populated
    Now you execute:
    printParts('Sparsely populated', tempParts);Inside procedure you execute:
    currentElement := p_collection.FIRST;
    This assingns currentElement value 2. Then procedure loops 5 times (collection element count is 5). Element 2 exists. Inside loop procedure executes:
    currentElement := p_collection.NEXT(currentElement);
    which assigns currentElement values 4,6,8,10 - all existing elements.
    Now second code. Everything is OK until you delete null elements. Again we have:
    2 - populated
    4 - populated
    6 - populated
    8 - populated
    10 - populated
    Again you execute:
    printParts('Sparsely populated', tempParts);Now procedure loops 5 times (i values are 1,2,3,4,5):
    FOR i IN 1 .. p_collection.COUNT
    Very first iteration assingns i value 1. And since collection has no element with substript 1 procedure raises no data found.
    SY.

  • Java call stored procedure with nested table type parameter?

    Hi experts!
    I need to call stored procedure that contains nested table type parameter, but I don't know how to handle it.
    The following is my pl/sql code:
    create or replace package test_package as
    type row_abc is record(
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    type matrix_abc is table of row_abc index by binary_integer;
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    END test_package;
    create or replace package body test_package as
    PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
    p_arg2 IN VARCHAR2,
    p_arg3 IN VARCHAR2,
    p_out OUT matrix_abc
    IS
    v_sn NUMBER(8):=0 ;
    BEGIN
    LOOP
    EXIT WHEN v_sn>5 ;
    v_sn := v_sn + 1;
    p_out(v_sn).col1 := 'col1_'||to_char(v_sn)|| p_arg1 ;
    p_out(v_sn).col2 := 'col2_'||to_char(v_sn)||p_arg2 ;
    p_out(v_sn).col3 := 'col3_'||to_char(v_sn)||p_arg3 ;
    END LOOP ;
    END ;
    END test_package ;
    My java code is following, it doesn't work:
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection
    ("jdbc:oracle:thin:@10.16.102.176:1540:dev", "scott", "tiger");
    con.setAutoCommit(false);
    CallableStatement ps = null;
    String sql = " begin test_package.test_matrix( ?, ? , ? , ? ); end ; ";
    ps = con.prepareCall(sql);
    ps.setString(1,"p1");
    ps.setString(2,"p2");
    ps.setString(3,"p3");
    ps.registerOutParameter(4,OracleTypes.CURSOR);
    ps.execute();
    ResultSet rset = (ResultSet) ps.getObject(1);
    error message :
    PLS-00306: wrong number or types of arguments in call to 'TEST_MATRIX'
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    Regards
    Louis

    Louis,
    If I'm not mistaken, record types are not allowed. However, you can use object types instead. However, they must be database types. In other words, something like:
    create or replace type ROW_ABC as object (
    col1 varchar2(16),
    col2 varchar2(16),
    col3 varchar2(16 )
    create or replace type MATRIX_ABC as table of ROW_ABC
    /Then you can use the "ARRAY" and "STRUCT" (SQL) types in your java code. If I remember correctly, I recently answered a similar question either in this forum, or at JavaRanch -- but I'm too lazy to look for it now. Do a search for the terms "ARRAY" and "STRUCT".
    For your information, there are also code samples of how to do this on the OTN Web site.
    Good Luck,
    Avi.

  • Jdeveloper pl/sql webservices with Nested Tables

    Hello
    I am using JDeveloper 10.1.3.1.0,I have created pl/sql webservice using the nested tables. This will insert the object data into database tables.after deplying the webservice into external oc4j, when I test the webservice locally with url: http://localmachine:8888/PL_SQL_WS-Nest_Obj_Webservice-context-root/ObjWebserviceSoapHttpPort
    The above web-services working and I am able to insert into the database tables.
    Same when I want to access through the application server, I have changed the wsdl file soap address as
    <soap:address location="http://10.91.20.7:8888/PL_SQL_WS-Nest_Obj_Webservice-context-root/ObjWebserviceSoapHttpPort"/>
    When I access this url, I am able to give the input data
    http://10.91.20.7:8888/PL_SQL_WS-Nest_Obj_Webservice-context-root/ObjWebserviceSoapHttpPort
    but the out from the web-service is:
    <env:Envelope
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Header/>
    <env:Body>
    <env:Fault
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <faultcode>env:Server</faultcode>
    <faultstring>Error creating target: DBConnImpMftest.ObjWebserviceUser</faultstring>
    <faultactor/>
    </env:Fault>
    </env:Body>
    </env:Envelope>
    Could any one help to solve the above issue?
    Kind regards
    Malathi

    try that !
    select a.*, case
    when a.item_type = 1 then b.inv_date
    when a.item_type = 3 then c.deb_date
    end as item_date
    from receipt_item a
    left join invoice b on a.item_id = b.invvi_id and a.item_type = 1
    left join Debit c on a.item_id = c.deb_id and a.item_type = 3

  • Problem when expanding Tree - Tree with nested table column

    Hi, i have created the tree using the Tree with nested table column.
    I have created a node called TREE_ROOT in the context.
    This node has few attributes which includes children_loaded, is_leaf, is_expanded.
    I have created the recursive node TREE_SUB for the above node TREE_ROOT.
    In the view, i have created the table with the master column. The above attributes have been mapped accordingly. I have created the action handler for load_children.
    In this action handler method, i receive the context_element correctly. In this method, i determine the children of the selected element and the resulting children are attached to this context_element.
    But the problem is: when i add elements to context_elements in the method load_children, these
    elements get added to the node TREE_ROOT as well.
    Please help.
    thanks and best regards,
    Pramod

    I just use some types defined in this user... Well, I hope you know what is the type definition of d_period_sec,
    don't you ? I didn't ask to provide all types existed now, only types you are
    using.
    Anyhow you have been granted with execute privilege for types you are using:
    SQL> conn tau_tll/tau_tll;
    Connected.
    SQL> create or replace type d_period_sec as object (date# date);
      2  /
    Type created.
    SQL> grant execute on d_period_sec to public with grant option;
    Grant succeeded.
    SQL> conn scott/tiger
    Connected.
    SQL> CREATE OR REPLACE TYPE unit_function AS OBJECT (
      2  xi NUMBER,
      3  yi NUMBER,
      4  xe NUMBER,
      5  ye NUMBER,
      6  xm NUMBER,
      7  ym NUMBER,
      8  v NUMBER,
      9  a NUMBER,
    10  f NUMBER,
    11  descr VARCHAR2 (20)
    12  );
    13  /
    Type created.
    SQL> grant execute on unit_function to master;
    Grant succeeded.
    SQL> CREATE OR REPLACE TYPE unit_moving_point AS OBJECT
      2  (
      3  p tau_tll.d_period_sec, -- from user TAU_TLL
      4 
      5  m unit_function
      6  )
      7  /
    Type created.
    SQL> grant execute on unit_moving_point to master;
    Grant succeeded.
    SQL> CREATE OR REPLACE TYPE moving_point_tab AS TABLE OF unit_moving_point;
      2  /
    Type created.
    SQL> grant execute on moving_point_tab to master;
    Grant succeeded.
    SQL> CREATE OR REPLACE TYPE moving_point AS OBJECT (u_tab moving_point_tab);
      2  /
    Type created.
    SQL> grant execute on moving_point to master;
    Grant succeeded.
    SQL> conn master/master
    Connected.
    SQL> CREATE TABLE MPOINTS (
      2  id NUMBER,
      3  mpoint scott.Moving_Point)
      4  NESTED TABLE mpoint.u_tab store as moving_tab;
    Table created.Rgds.

  • Import tables with nested table : ORA-00600

    In Oracle 9.2
    Create object, type as table, and table with nested table (store as syms_ntab) are successfully.
    Also its export.
    In process of import on another server (also 9.2, 'fromuser=one touser=two') shows errors:
    . . importing table "SYMS_NTAB"
    IMP-00058: ORACLE error 600 encountered
    ORA-00600: internal error code, arguments: [kokeeafi1], [2], [2], [], [], [], [], []
    IMP-00075: Warning: The nested table may contain partial rows or duplicate rows
    But for all that table is created and error occur on phase inserting strings.
    What is this?
    In Oracle 8.0.5 i perform similar operation without error.

    From Oracle error messages and codes manual:
    ORA-00600 internal error code, arguments: [string], [string], [string], [string], [string], [string], [string], [string]
    Cause: This is the generic internal error number for Oracle program exceptions. It indicates that a process has encountered a low-level, unexpected condition. Causes of this message include:
    * timeouts
    * file corruption
    * failed data checks in memory
    * hardware, memory, or I/O errors
    * incorrectly restored files
    The first argument is the internal message number. Other arguments are various numbers, names, and character strings. The numbers may change meanings between different versions of Oracle.
    Action: Report this error to Oracle Support Services after gathering the following information:
    * events that led up to the error
    * the operations that were attempted that led to the error
    * the conditions of the operating system and databases at the time of the error
    * any unusual circumstances that occurred before receiving the ORA-00600 message
    * contents of any trace files generated by the error
    * the relevant portions of the Alter files
    Note: The cause of this message may manifest itself as different errors at different times. Be aware of the history of errors that occurred before this internal error.

  • Trying to UNION two views with nested tables

    I am using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod, and my objective is to generate some XML. What I have been doing in the past, is to create a view, and then pass that view to the DBMS_XMLQuery routine. This gives me a CLOB that I pass along to the application. A typical object would be something like:
    create or replace type XML_UGroup_Member_Type as object (
         username          varchar2(128),
         group_key          varchar2(128));
    create or replace type XML_UGroup_Member_List
        as table of XML_UGroup_Member_Type;
    show errors
    Create or replace type XML_UGroup_Type as object (
         Group_Space     varchar2(32),
         group_key     varchar2(128),
         group_name     varchar2(255),
         members          XML_UGroup_Member_List);
    /This particular application will be doing stuff with group information. Pretty simply types - a group with a name and a few other keys, and a list of members. A sample view would be like:
    create or replace view xml_department_ugroup_view of xml_ugroup_type
      with object identifier ( group_key ) as
      Select 'Department',
          'Department:' || orgn_code,
          'Department_' || orgn_name
          cast ( multiset (
               select  Username, person_id,
                        'Department:' ||  effective_orgn
                from directory_master dm, logins l
               where effective_orgn = dd.orgn_code
                 and dm.person_id = l.owner)
                as XML_UGroup_Member_List )
             as members
       from directory_departments dd
      where dept_include = 'Y';
    can select from this view, and I can pass it to the DBMS_XMLQUERY package and get a nice XML document. What I want to is essentially put several of these views together, like
    Select * from XML_Department_Ugroup_View
    Union
    Select * from XML_Portfolio_Ugroup_View;But UNION does not work with nested tables:
    ERROR at line 1: ORA-00932: inconsistent datatypes: expected - got SIMON.XML_UGROUP_MEMBER_LIST
    What I was hoping to do, was to develop a set of sub views for each of the group "spaces", and then generate a view/object that includes all of the sub views, and be able to operate with that single object.
    Thoughts on how to make this work, or on alternate approaches? I have considered calling XMLQuery on each of the sub views and concatenating the XML documents and returning that to the application, but I was hoping to find a more "unified" approach.

    I modified my approach a bit - I changed the base views to return an XMLType object, like:
    create or replace view xml_portfolio_ugroup_xml
    as
    Select XMLElement("group",
             xml_ugroup_type(
          'Portfolio',
             'Portfolio:' || coas_code || ':' || orgn_Code,
          cast ( multiset (
               select  Username,
                from directory_master dm, logins l
               where ( effective_orgn, effective_coas ) in
               where effective_orgn = dd.orgn_code
                  and dm.person_id = l.owner
                as XML_UGroup_Member_List ))) as grp
       from directory_departments dd
      where dept_include = 'Y';and then I combined them with something like the following (I expect to adjust this as I learn more about the XML DB support)
    create or replace view xml_ugroup_xml as
      select xmlconcat(
         (select xmlagg(grp) from xml_department_ugroup_xml),
         (select xmlagg(grp) from xml_portfolio_ugroup_xml)
         ) as GROUPS
         from dualand as I define more group branches, I can add them into the XMLConCat stanzas. I am still open to suggestions as to ways of doing this better or cleaner, but this at least gets the project moving forward again.

  • Partition exchange error on table with nested table

    On Oracle 11.2.0.1, I have a partitioned table with some partitions that need to be 'archived' (in terms of moving partitions to an 'archive' table).
    I have a source table like:
    CREATE TABLE IS_PODACI245
      ID_OBJEKTA_IDENTIFIKACIJA  NUMBER(10),
      ID_OBJEKTA                 NUMBER(20),
      DATUM                      TIMESTAMP(6)       NOT NULL,
      TZ                         NUMBER(3),
      DATA1                      NUMBER(10),
      DATA2                      NUMBER(6),
      DATA3                      NUMBER(10),
      DATA4                      NUMBER,
      DATA5                      T_NTCIP_CLIMATE_TABLE
    NESTED TABLE DATA5 STORE AS IS_PODACI245_STORE_TABLE
    TABLESPACE DATA
    PARTITION BY RANGE (DATUM)
      PARTITION P_201107 VALUES LESS THAN (TIMESTAMP' 2011-08-01 00:00:00')
        LOGGING
        NOCOMPRESS
        TABLESPACE DATA, 
      PARTITION P_MAXVALUE VALUES LESS THAN (MAXVALUE)
        LOGGING
        NOCOMPRESS
        TABLESPACE DATA
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE INDEX IDX_IS_PODACI245_KOMPLEKS ON IS_PODACI245
    (ID_OBJEKTA_IDENTIFIKACIJA, ID_OBJEKTA, DATUM)
      TABLESPACE DATA
    LOCAL ( 
      PARTITION P_201107
        LOGGING
        NOCOMPRESS
        TABLESPACE DATA, 
      PARTITION P_MAXVALUE
        LOGGING
        NOCOMPRESS
        TABLESPACE DATA
    NOPARALLEL;
    CREATE OR REPLACE TYPE t_ntcip_climate_table as table of t_ntcip_climate_fmt;
    CREATE OR REPLACE TYPE t_ntcip_climate_FMT as object
    (  dev_index number(6)
    ,   dev_description varchar2(512)
    ,   dev_type number(10)
    ,   dev_status number(10)
    ,   dev_mfr_status varchar2(512)
    ,   dev_active number(3)
    ,   dev_test_activation number(10)
    /I would like to make exchange partition using stage table, and everything is going fine on all tables, but only on a few of them (listed source is one of them, and they're only tables with nested tables wihin), where I get an error.. but sometimes ;)
    on a statement like:
    ALTER TABLE IS_PODACI245_ARH EXCHANGE PARTITION P_201106  WITH TABLE IS_PODACI245_STAGE EXCLUDING INDEXES  WITHOUT VALIDATION;I got an error:
    ORA-00001: unique constraint (TXV.SYS_C0032911) violated
    it's an unique index between parent and nested table.
    what could cause that problem?

    Dear,
    I suppose that the unique constraint
    ORA-00001: unique constraint (TXV.SYS_C0032911) violatedis the one you 've created on the nested table IS_PODACI245_STORE_TABLE
    If so, why not disable that constraint and try again.
    I have never exchanged such a kind of partitioned table having a nested table in it. But, I could imagine that the cloned non partitioned table IS_PODACI245_STAGE should at least be the exact image of the partitioned table IS_PODACI245_ARH (of course without the partition part) but with the nested table part and including all indexes
    In addition, if you have a parent/child relationship between your partitioned tables, then there is a chronological order of exchange starting by the child and then finishing by the parent
    see the following link for more information about this order of exchange (and comment 2 for an example also)
    http://jonathanlewis.wordpress.com/2006/12/10/drop-parent-partition/#more-65
    Hope this helps
    Mohamed Houri

  • ANSI Standard Join with Nested Table

    Does anyone know how to (or whether you actually can) use ansi standard table joins with nested tables.
    Non-ansi standard would look something like this
    SELECT e.empno
    FROM departments d, TABLE(d.employees) e
    WHERE d.deptno = 10;
    Where d.employees is a nested table.
    But if I try ansi-standard I like such:
    SELECT e.empno
    FROM departments d
    JOIN TABLE(d.employees) e
    WHERE d.deptno = 10;
    I get
    ORA-00905: missing keyword
    because I have nothing to join it on.
    Your help is very much appreciated

    Both replies worked fine.
    I think I will go with the NATURAL JOIN as it seems the cleanest option.
    Thanks Guru 2748

  • Fill datagridview with Nested Table Object Type ???

    Hello everybody, please you help me resolve my problem?
    I follow this example: *(A Sample Application using Object-Relational features)* http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10799/adobjxmp.htm
    And this tutorial: *(Using Oracle User-Defined Types with .NET and Visual Studio)* http://www.oracle.com/technology/obe/hol08/dotnet/udt/udt_otn.htm
    Now I have 3 Object Table: Stock, Customer and Purchase Order. With the tutorial it's OK to show the data of Stock and Customer Table [there is no nested table in], but I can't do this with table Purchase Order, the tutorial don't show how to work with Nested Table type [Missing or something ?]
    When I try to display the data of table Purchase Order, I get the error:
    typeName='LINEITEMLIST_NTABTYP'' is not specified or is invalid*
    Follow the tutorial, I generate custom class for this UDT and get another error:
    this.STOCK_REF = ((object)(Oracle.DataAccess.Types.OracleUdt.GetValue(con, pUdt, "STOCK_REF")));*
    Argument Exception Unhandle: Object attribute is not mapped to a custom type member.*
    Can You show me how to do this ? Show the data of the Nested Table in Visual Studio, do I have something wrong ??? Thanks and Best Regards.

    I think you need to go through the tutorial more carefully. I think you are missing steps.
    You are using a REF. Are you creating an object table for the objects to be stored in? Are you dereferencing the REF? This is covered by the Oracle by Example tutorial.
    http://www.oracle.com/technology/obe/hol08/dotnet/udt/udt_otn.htm#t11
    When you receive the nested table, it will be inside a .NET class. You can create this class by using the Create Custom Class menu item on the nested table type in server explorer.
    This class will contain a ToString method and a ToXML method.
    The question is, where are you attempting to display the data from this nested table? In a grid?
    Does it make sense to display a nested table inside one cell of a grid? No. You would need to construct a special UI that will show the
    nested table. Maybe the user clicks on the cell on the grid, which opens a new grid that displays the data. Or maybe there is a second grid on the form that always shows the nested table for the row that the first grid currently has selected.
    I realize I am not providing you the code... but it sounds like you need to design a more sohisticated UI than what the tutorial is using -- one that can handle displaying one additional table per row.

  • Using SQL with Nested Table

    Hi ,
    Please assist as how can we do this thing
    i have a nested table of object type
    create or replace type a1 as object
    a number,
    b varchar2(30),
    region varchar2(30)
    create type a1_array s table of a1;
    declare
    v_a1 a1;
    v_a1_array a1_array:=a1_array();
      begin
    v_a1= a1(1, '1' , 'AUS');
    v_a1_array.EXTEND;
    v_a1_array(1):=v_a1;
    v_a1= a1(2, '2' , 'AUS');
    v_a1_array.EXTEND;
    v_a1_array(2):=v_a1;
    v_a1= a1(3, '3' , 'NAM');
    v_a1_array.EXTEND;
    v_a1_array(3):=v_a1;
      end;
    Now, i have v_a1_array having 3 rows 2 with AUS region and one with NAM region.
    Using SQL can i extract only 'AUS'  rows and fetch in  ARRAY OF TYPE v_a1_array (using Where clause  and Table () functions )
    Any help will be highly appreciated. Please assist. I have oracle 11g
    Thanks

    Hi,
    GPU has already shown you how to do. I will just modify my original one:
    SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 22 22:14:42 2013
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2     v_a1           a1;
      3     v_a1_array     a1_array := a1_array ();
      4     v_a1_array2    a1_array;
      5  BEGIN
      6     v_a1 := a1 (1, '1', 'AUS');
      7     v_a1_array.EXTEND;
      8     v_a1_array (1) := v_a1;
      9     v_a1 := a1 (2, '2', 'AUS');
    10     v_a1_array.EXTEND;
    11     v_a1_array (2) := v_a1;
    12     v_a1 := a1 (3, '3', 'NAM');
    13     v_a1_array.EXTEND;
    14     v_a1_array (3) := v_a1;
    15
    16     SELECT a1(a, b, region)
    17       BULK COLLECT INTO v_a1_array2
    18       FROM TABLE (v_a1_array)
    19      WHERE region = 'AUS';
    20
    21     FOR c1 IN (SELECT *
    22                  FROM TABLE (v_a1_array2))
    23     LOOP
    24        DBMS_OUTPUT.put_line ('A='||c1.a||', B='||c1.b||', REGION='||c1.region);
    25     END LOOP;
    26  END;
    27  /
    A=1, B=1, REGION=AUS
    A=2, B=2, REGION=AUS
    PL/SQL procedure successfully completed.
    If you consider your question answered, please mark this thread as answered.
    Regards.
    Alberto

  • "member of " not working with nested table of dates

    Can someone explain why this doesn't work. The last select does not return any row. When trying the same with a table of number, it works fine.
    drop table test;
    drop type date_tab;
    create type date_tab as table of date;
    create table test(dates date_tab) nested table dates store as dates;
    insert into test values (date_tab(to_date('10-jan-2007'),to_date('15-jan-2007'),to_date('15-jan-2007')));
    commit;
    select * from test where to_date('10-jan-2007') member of dates;
    Line above should find the row, but does not return anything.

    > With 10G Oracle said that these two engines are now sharing the same source code
    Is that documented somewhere? Regarding database versions, it was 9.0.1 that claimed an integrated parser. I don't see any update for 10g.
    > So in the old days one had to do a [SELECT sysdate INTO d FROM dual] to assign a function value to a PL/SQL var - as the function did not exist in PL/SQL.
    Then (from Oracle 7 onwards?) these functions were also available in PL/SQL. However, the two engines did not share common code. So functions in SQL did not always behave like function in PL/SQL and vice versa.
    I don't recall that limitation in PL/SQL v1 (Forms 3 to 4.5, and database v6, though I doubt many people actually used PL/SQL on the database because (1) it was separately licensed, and (2) it didn't have stored procedures) - but then it was a while ago so I could be mistaken.
    I know USER, SYSDATE and others used to be implicit queries of dual (i.e. the supplied PL/SQL function was just a wrapper containing SELECT SYSDATE INTO dt FROM dual; RETURN dt;) although that's probably just confusing the issue.

  • DBMS_SQL.BIND_VARIABLE with nested table and ORA-600

    Hello, I'm experimenting a little with pl/sql and I was trying to do some dynamic SQL using DBMS_SQL, but I'm having a problem when binding a variable that is a neste table(got no problems in the same example if I bind with a varchar2 variable).
    Here is a reduction of the problem:
    DECLARE
         TYPE CENA_TYPE IS TABLE OF VARCHAR2(30);
         CENA CENA_TYPE;
         L_UPDATE_STMT VARCHAR2(2000);
         UPDATE_CURSOR INTEGER:=DBMS_SQL.OPEN_CURSOR;
         RES INTEGER;
    BEGIN
         CENA:=CENA_TYPE('HELLO');
         L_UPDATE_STMT:= 'BEGIN '
                             ||'DBMS_OUTPUT.PUT_LINE(:CENA(1));'
                             ||'END;';
         DBMS_SQL.PARSE(UPDATE_CURSOR, L_UPDATE_STMT ,DBMS_SQL.NATIVE);
         DBMS_SQL.BIND_VARIABLE(UPDATE_CURSOR,':CENA',CENA);
         RES:=DBMS_SQL.EXECUTE(UPDATE_CURSOR);
         DBMS_SQL.CLOSE_CURSOR(UPDATE_CURSOR);
    END;
    /What am I doing wrong??
    Thanks

    Pedro_gloria wrote:
    What am I doing wrong??DBMS_SQL executes in own context. Therefore, even though type CENA_TYPE is declared in calling anonymous block it is not known to anonymous block you execute in DBMS_SQL. Also, you must initialize and extend collection. Use:
    SQL> set serveroutput on
    SQL> DECLARE
      2   L_UPDATE_STMT VARCHAR2(2000);
      3   UPDATE_CURSOR INTEGER:=DBMS_SQL.OPEN_CURSOR;
      4   RES INTEGER;
      5  BEGIN
      6   L_UPDATE_STMT:= 'DECLARE
      7   TYPE CENA_TYPE IS TABLE OF VARCHAR2(30);
      8   CENA CENA_TYPE := CENA_TYPE();
      9          BEGIN '
    10       ||'CENA.extend;'
    11       ||'CENA(1) := :1;'
    12       ||'DBMS_OUTPUT.PUT_LINE(CENA(1));'
    13       ||'END;';
    14   DBMS_SQL.PARSE(UPDATE_CURSOR, L_UPDATE_STMT ,DBMS_SQL.NATIVE);
    15   DBMS_SQL.BIND_VARIABLE(UPDATE_CURSOR,':1','Hello');
    16   RES:=DBMS_SQL.EXECUTE(UPDATE_CURSOR);
    17   DBMS_SQL.CLOSE_CURSOR(UPDATE_CURSOR);
    18  END;
    19  /
    Hello
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Explian plan with nested tables

    I am having an issue with getting an explain plan on a query that uses a nested table. In my tkprof output I am getting the error message.
    error during execute of EXPLAIN PLAN statement
    ORA-00932: inconsistent datatypes: expected - got CHAR
    Below is a copy of the tkprof output, the code for my oracle type, and the code for my pl/sql procedure.
    Thanks,
    CP
    INSERT
    INTO cp_temp_1
    (col_1)
    SELECT ct0.col_2
    FROM TABLE(CAST(:b1 AS tab_id)) vi
    INNER JOIN cp_temp_0 ct0 ON ct0.col_1 = vi.id
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.01 5 19 5 8
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.00 0.01 5 19 5 8
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 71 (CPARK) (recursive depth: 1)
    Rows Row Source Operation
    8 MERGE JOIN
    8 SORT JOIN
    8 TABLE ACCESS FULL CP_TEMP_0
    8 SORT JOIN
    2 COLLECTION ITERATOR PICKLER FETCH
    error during execute of EXPLAIN PLAN statement
    ORA-00932: inconsistent datatypes: expected - got CHAR
    parse error offset: 190
    DROP TYPE tab_id;
    DROP TYPE obj_id;
    CREATE TYPE obj_id AS OBJECT
    (id INTEGER);
    SHOW ERRORS
    CREATE TYPE tab_id AS TABLE OF obj_id;
    SHOW ERRORS
    CREATE OR REPLACE PROCEDURE cpark.prc_cp_test
    IS
    CURSOR cur_cp_test
    IS
    SELECT obj_id(col_1)
    FROM (SELECT DISTINCT
    col_1
    FROM cp_temp_0);
    v_ids tab_id := tab_id();
    BEGIN
    OPEN cur_cp_test;
    FETCH cur_cp_test BULK COLLECT INTO v_ids;
    CLOSE cur_cp_test;
    INSERT
    INTO cp_temp_1
    (col_1)
    SELECT ct0.col_2
    FROM TABLE(CAST(v_ids AS tab_id)) vi
    INNER JOIN cp_temp_0 ct0 ON ct0.col_1 = vi.id;
    END;
    SHOW ERRORS
    CREATE TABLE CP_TEMP_0 (
    COL_1 INTEGER,
    COL_2 INTEGER)
    TABLESPACE USERS
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    NOCACHE;
    CREATE TABLE CP_TEMP_1 (
    COL_1 INTEGER)
    TABLESPACE USERS
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    NOCACHE;
    D:\oracle\admin\play\udump>tkprof play_ora_3792.trc trc_01.txt EXPLAIN=cpark/password@play SORT=EXEELA,FCHELA

    and the complete example
    SQL> create or replace TYPE t_indirizzo AS OBJECT (
      2  via VARCHAR(45),
      3  numero NUMBER,
      4  cap INTEGER(5),
      5  citta VARCHAR(30),
      6  provincia VARCHAR(30),
      7  regione VARCHAR(30)
      8  );
      9  /
    Type created.
    SQL>
    SQL>
    SQL> create or replace TYPE t_telefono AS OBJECT (
      2  num_tel NUMBER(15)
      3  );
      4  /
    Type created.
    SQL>
    SQL> create or replace TYPE t_listaTelefono AS TABLE OF t_telefono
      2  /
    Type created.
    SQL>
    SQL> create or replace TYPE t_cliente AS OBJECT (
      2  cod_cliente NUMBER(8),
      3  indirizzo t_indirizzo,
      4  email VARCHAR(30),
      5  telefono t_listaTelefono
      6  ) NOT FINAL;
      7  /
    Type created.
    SQL>
    SQL> CREATE TABLE cliente OF t_cliente(
      2  cod_cliente NOT NULL,
      3  indirizzo NOT NULL,
      4  email NOT NULL,
      5  PRIMARY KEY (cod_cliente)
      6  ) nested table telefono store as numTelCli_tab
      7  return as value
      8  /
    Table created.
    SQL>

Maybe you are looking for

  • Mpd and gnome startup applications [SOLVED]

    i am using mpd as a regular user (i couldnt get the permissions right when trying to follow the wiki's instructions) so to start mpd i must execute: mpd ~/.mpd/config however, that doesnt work when pasted into gnome's startup applications, it also do

  • My iPod doesn't display certain videos, it only plays the sound.

    The files are in .mp4 format. I have them in my iTunes as well. I tried to play them in there and I have the same problem. However, in iTunes the files have a thumbnail picture. I have managed to play all of the files in Media Player. They work fine

  • Authorization to change/create orders

    hi friends, is there a way to restrict a user in creating/changing order in webui? i found UIU_COMP , which takes component, ip plug, and window, but does this help me? i want to restrict users in creating/editing orders, ie the components are BT115H

  • Column highlighting

    Is it possible to highlight a column in interactive report ? Sanjay

  • Install Precalculation server on Virtual Windows system

    Hi  Friends, Is it possible to install Precalculation server on Virtual windows system? Thanks & Regards Prasanth