Insert & update nested table

Hi
I have created one nested table with the follwing columns. I have to insert records into the nested table. And also I have to update the nested table. Please find below my table and getting error message.
Please advose...!!
SQL> create type details as object(
  2  basic number(7,2),
  3  da number(6,2),
  4  hra number(6,2),
  5  pf number(6,2),
  6  it number(6,2),
  7  gross number(7,2),
  8  ded number(6,2),
  9  net number(8,2));
10  /
Type created.
SQL> create type details_t is table of details;
  2  /
Type created.
SQL> ed
Wrote file afiedt.buf
  1  create table emp_tab(empno number(4),name varchar2(10),details_tab details_t)
  2* nested table details_tab store as empl_details
SQL> /
Table created.
SQL> ed
Wrote file afiedt.buf
  1* insert into emp_tab values(&empno,'&name',details_t(details(&da,&hra,&pf,&it,null,null,null)))
SQL> /
Enter value for empno: 1
Enter value for name: asdf
Enter value for da: 120
Enter value for hra: 130
Enter value for pf: 120
Enter value for it: 120
old   1: insert into emp_tab values(&empno,'&name',details_t(details(&da,&hra,&pf,&it,null,null,null
new   1: insert into emp_tab values(1,'asdf',details_t(details(120,130,120,120,null,null,null)))
insert into emp_tab values(1,'asdf',details_t(details(120,130,120,120,null,null,null)))
ERROR at line 1:
ORA-02315: incorrect number of arguments for default constructorCan I use '&' while inserting records into nested table? yes / no ?
I have to update gross, ded, net columns also..!!
Please help me..!!
Regards
A

zep@dev>
zep@dev> create type details as object
      2  (
      3      basic number(7, 2),
      4      da    number(6, 2),
      5      hra   number(6, 2),
      6      pf    number(6, 2),
      7      it    number(6, 2),
      8      gross number(7, 2),
      9      ded   number(6, 2),
     10      net   number(8, 2)
     11  )
     12  /
Type created
zep@dev> create type details_t is table of details
      2  /
Type created
zep@dev> create table emp_tab(empno number(4),name varchar2(10),details_tab details_t)
      2     nested table details_tab store as empl_details
      3  /
Table created
zep@dev> insert into emp_tab
      2  values
      3      (1,
      4       'asdf',
      5       details_t(details(120, 130, 120, 120, 1, 2, 3, 4)));
1 row inserted
zep@dev>
zep@dev>   select *
      2      from table (select details_tab
      3                    from emp_Tab t
      4                   where t.empno = 1);
    BASIC       DA      HRA       PF       IT     GROSS      DED        NET
   120,00   130,00   120,00   120,00     1,00      2,00     3,00       4,00
zep@dev> -- second object in the same empno = 1
zep@dev>    insert into table
      2         (select details_tab
      3            from emp_Tab t
      4           where t.empno = 1)
      5     values
      6         (details(200, 230, 220, 220, 10, 11, 12, 13));
1 row inserted
zep@dev>
zep@dev> select *
      2    from table (select details_tab
      3                  from emp_Tab t
      4                 where t.empno = 1);
    BASIC       DA      HRA       PF       IT     GROSS      DED        NET
   120,00   130,00   120,00   120,00     1,00      2,00     3,00       4,00
   200,00   230,00   220,00   220,00    10,00     11,00    12,00      13,00
zep@dev>
zep@dev> update table (select details_tab
      2                  from emp_Tab t
      3                 where t.empno = 1)
      4     set gross = nvl(basic,0) + nvl(da,0) + nvl(hra,0),
      5         ded   = nvl(pf,0) + nvl(it,0),
      6         net   = nvl(gross,0) - nvl(ded,0)
      7   where basic = 120;
1 row updated
zep@dev>
zep@dev> select *
      2    from table (select details_tab
      3                  from emp_Tab t
      4                 where t.empno = 1);
    BASIC       DA      HRA       PF       IT     GROSS      DED        NET
   120,00   130,00   120,00   120,00     1,00    370,00   121,00      -1,00
   200,00   230,00   220,00   220,00    10,00     11,00    12,00      13,00
zep@dev>

Similar Messages

  • How to update Nested tables with xsu

    Hello,
    I have three tables.
    1) DEPARTMENT_TAB
    2) EMPLOYEE_TYP
    3) ADDRESS_TYP
    ADDRESS_TYP is a collection and it is nested inside EMPLOYEE_TYP.
    EMPLOYEE_TYP is a collection and it is nested inside DEPARTMENT_TAB.
    created with below scropt
    CREATE TYPE ADDRESS_TYP AS OBJECT (CITY VARCHAR2(10), STATE VARCHAR2(2));
    CREATE TYPE ADDRESS_TYP_NT AS TABLE OF ADDRESS_TYP;
    CREATE TYPE EMPLOYEE_TYP AS OBJECT (EMPNO NUMBER(4), ENAME VARCHAR2(10), ADDRESS_VAR ADDRESS_TYP_NT);
    CREATE TYPE EMPLOYEE_TYP_NT AS TABLE OF EMPLOYEE_TYP;
    CREATE TABLE DEPARTMENT_TAB (DEPTNO NUMBER(4), DNAME VARCHAR2(10), EMPLOYEE_VAR EMPLOYEE_TYP_NT)
         NESTED TABLE EMPLOYEE_VAR STORE AS EMPLOYEE_TAB
         ( NESTED TABLE ADDRESS_VAR STORE AS ADDRESS_TAB);
    I inserted two rows in DEPARTMENT_TAB and their nested tables using normalsql. and i generated below xml content using XSU java API
    oracle.xml.sql.query.OracleXMLQuery
    My Question is How to UPDATE a row in ADDRESS_TAB using XSU java API
    oracle.xml.sql.dml.OracleXMLSave.
    (When i was trying to update address_tab nested table's row with xml input file. it is deleting other existing rows)
    Thanks.

    Why do you say it does not work?

  • How to update nested table records ??

    Hi, I am just starting to write anything in PL/SQL and having some difficulties with basic syntax. Thanks for any help in advance.
    My problem is how to update collection (nested table of objects) with SQL statement. My nested table is not a column of regular table.
    Example:
    CREATE OR REPLACE TYPE tmpRec AS OBJECT(
    Col1 INT,
    Col2 INT
    CREATE OR REPLACE TYPE tmpTable IS TABLE OF tmpRec;
    DECLARE v tmpTable :=
    tmpMBATable(
    tmpRec(1,1),
    tmpRec(2,2),
    tmpRec(3,3),
    BEGIN
    --UPDATE TABLE(CAST(v AS tmpTable)) T SET T.Col2 = 1 WHERE T.Col1 =1;
    --UPDATE TABLE(v) T SET T.Col2 = 12 WHERE T.Col1 =1;
    --UPDATE (SELECT * FROM TABLE(v) )T SET T.Col2 = 12 WHERE T.Col =1;
    END;
    I am getting either
    PL/SQL: ORA-22841: DML is not allowed on PL/SQL Collections
    OR
    PL/SQL: ORA-00903 Bad table name.
    I found there is no problem when collection is a column of DB table (UPDATE TABLE(select collection_column from table) T SET T.Col2 = 12 WHERE T.Col1 =1;) but i want it to be just a collection without storing it in DB, is it possible ?
    Please help.

    898539 wrote:
    Thanks, for fast answer but my problem is more complex, maybe you can show me some workaround i try to use collection but maybe i should do something else...A complex problem does not mean a complex solution. In fact, complex problems should ideally be solved by breaking the complexity down into simpler components and then solving each of these in turn.
    As far as nested tables go? An interesting feature. But one that I will need a lot of convincing and justification for to consider for a production system. There are some major limitations with using nested tables. And these do not exist when using the simpler form of a standard relational child table instead.
    I am migrating from Sybase Adaptive Server Enterprise and searching for sollution for something we used temporary tables for so far.Temporary tables in Sybase are typically used to prevent concurrency issues (readers and writers blocking one another). Thus make a temp copy of the data and do not prevent concurrent access to the source data itself.
    These reasons simply do not exist in Oracle. In most cases, using temporary tables in Oracle simply because that is how it was implemented in Sybase, would be fundamentally flawed.
    Oracle is not Sybase. It does a very poor imitation of Sybase.
    I need a collection that can store some data and I need to be able to use it as a table so I can join to it via SQL query or call some DML on it.Why do you need a collection? The best place for data in Oracle is inside a table. Not inside a collection - especially not if that collection resides in PGA memory in the PL/SQL engine.
    In my store procedure I am updating, deleteing and inserting some data to it depends on context.What context? Oracle supports context namespaces - often used for virtual private database (VPDB) implementations. If you are referring to scope instead - there are a number of ways that Oracle supports scope too.
    The bottom line is that you should not approach this problem with "+how do I convert this Sybase method into an Oracle method+". Instead you need to look at the business requirement that the Sybase method addresses and then determine how best to address that requirement using Oracle.

  • Update Nested Table Problem

    Hi All,
    I have a update problem in nested table.
    Below is my query:
    CREATE OR REPLACE TYPE TRACER.SEARCH_DATA AS TABLE OF VARCHAR2(20);
    UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM
    SET NOT_FOUND_SOR_LOT_NUM = SEARCH_DATA(
    SELECT
    COLUMN_VALUE
    FROM
    TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
    WHERE
    TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
    ) WHERE JOB_ID = 8;
    ORA-00936: missing expression
    or I try as following
    DECLARE
    sor_lot_num_not_found SEARCH_DATA :=
    SEARCH_DATA
    SELECT
    FROM
    TABLE (SELECT SORTING_LOT_NUMBER FROM TRACER_SEARCH_SCHEDULE_LOT_NUM WHERE JOB_ID = 8)
    WHERE
    TRIM(COLUMN_VALUE) NOT IN (SELECT DISTINCT (SORTING_LOT_NUMBER) FROM SEARCH_SCHEDULE_RESULT_LOT_NUM WHERE JOB_ID = 8)
    BEGIN
    UPDATE TRACER_SEARCH_SCHEDULE_LOT_NUM SET NOT_FOUND_SOR_LOT_NUM = sor_lot_num_not_found WHERE JOB_ID = 8;
    END;
    ORA-06550: line 5, column 9:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( ) - + case mod new not null others <an identifier>
    table avg count current exists max min prior sql stddev sum
    variance execute multiset the both leading trailing forall
    merge year month DAY_ hour minute second timezone_hour
    timezone_minute timezone_region timezone_abbr time timestamp
    interval date
    <a string literal with character set specificat
    ORA-06550: line 11, column 5:
    PLS-00103: Encountered the symbol ")" when expecting one of the following:
    ; for and or group having intersect minus order start union
    where connect
    ORA-06550: line 14, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted d
    I have try on the Select Statement, it work. So is it the way that I assign data from nested table and update method is wrong?
    Edited by: skymonster84 on Mar 8, 2011 5:12 PM

    Hi,
    I think MULTISET operators might interest you.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/operators006.htm
    Not tested :
    UPDATE tracer_search_schedule_lot_num
    SET not_found_sor_lot_num =
          sorting_lot_number
          MULTISET EXCEPT ALL
          CAST(
            MULTISET(
              SELECT distinct sorting_lot_number
              FROM search_schedule_result_lot_num
              WHERE job_id = 8
            AS search_data
    WHERE job_id = 8
    ;

  • Is there any API to insert/update RA_TERRITORIES table

    Hi
    I have to create diff territory combinations for new customer creation.
    Is there any API for inserting records to RA_TERRITORIES table.
    I did n,t find any thing related to this.
    Thanks&Regards
    RS

    Hi,
    Thanks for the reply,
    But JTF_TERRITORY_PUB is not updating ra_territories table.
    I think its not useful for my purpose.

  • Insert with Nested Table

    Hi,
    I have a table called time_slots
    CREATE OR REPLACE TYPE type_timeslots AS TABLE OF DATE;
    CREATE TABLE time_slots
    time_code VARCHAR2(50),
    TIME_SLOT TYPE_TIMESLOTS
    NESTED TABLE TIME_SLOT STORE AS NESTED_TIME_SLOTS
    I have a SQL which returns multiple rows for each period_code, as I need to insert data into the above table based on a source table.
    But I don't know how to do this.
    For example, I have a SQL which returns
    Time Code Slots
    OPENH 09:00
    OPENH 10:00
    OPENH 11:00
    CLOSH 12:00
    CLOSH 13:00
    CLOSH 14:00
    NOH 15:00
    NOH 16:00
    So, I want the INSERT statement to insert 3 rows into the table and the slots collected into the nested table. I don't know how to merge the 3 rows that relate to OPENH into 1 row with a collection for the slots.
    I want to do this in SQL rather than PL/SQL.
    Please help.
    Thanks
    M

    To insert from a select statement, you can use the collect function to group the time slots into your collection for each distinct time code. See below. I've created a view called "sample_data" just to make the examples easier.
    SQL> CREATE OR REPLACE TYPE type_timeslots AS TABLE OF DATE;
      2  /
    Type created.
    SQL> CREATE TABLE time_slots
      2  (
      3  time_code VARCHAR2(50),
      4  time_slot TYPE_TIMESLOTS
      5  )
      6  NESTED TABLE TIME_SLOT STORE AS NESTED_TIME_SLOTS;
    Table created.
    SQL> CREATE VIEW sample_data
      2  AS
      3     SELECT 'OPENH' AS time_code, TO_DATE('09:00','HH24:MI') AS time_slot FROM dual
      4     UNION ALL
      5     SELECT 'OPENH' AS time_code, TO_DATE('10:00','HH24:MI') AS time_slot FROM dual
      6     UNION ALL
      7     SELECT 'OPENH' AS time_code, TO_DATE('11:00','HH24:MI') AS time_slot FROM dual
      8     UNION ALL
      9     SELECT 'CLOSH' AS time_code, TO_DATE('12:00','HH24:MI') AS time_slot FROM dual
    10     UNION ALL
    11     SELECT 'CLOSH' AS time_code, TO_DATE('13:00','HH24:MI') AS time_slot FROM dual
    12     UNION ALL
    13     SELECT 'CLOSH' AS time_code, TO_DATE('14:00','HH24:MI') AS time_slot FROM dual
    14     UNION ALL
    15     SELECT 'NOH' AS time_code, TO_DATE('15:00','HH24:MI') AS time_slot FROM dual
    16     UNION ALL
    17     SELECT 'NOH' AS time_code, TO_DATE('16:00','HH24:MI') AS time_slot FROM dual
    18     ;
    View created.
    SQL> SELECT time_code
      2  ,      CAST(COLLECT(time_slot) AS type_timeslots) AS time_slot
      3  FROM   sample_data
      4  GROUP  BY
      5         time_code;
    TIME_CODE TIME_SLOT
    CLOSH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    NOH       TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08')
    OPENH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    SQL> INSERT INTO time_slots (time_code, time_slot)
      2  SELECT time_code
      3  ,      CAST(COLLECT(time_slot) AS type_timeslots) AS time_slot
      4  FROM   sample_data
      5  GROUP  BY
      6         time_code;
    3 rows created.
    SQL> SELECT * FROM time_slots;
    TIME_CODE TIME_SLOT
    CLOSH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    NOH       TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08')
    OPENH     TYPE_TIMESLOTS('01-DEC-08', '01-DEC-08', '01-DEC-08')
    SQL> SELECT t.time_code
      2  ,      TO_CHAR(nt.column_value, 'HH24:MI') AS time_slot
      3  FROM   time_slots         t
      4  ,      TABLE(t.time_slot) nt;
    TIME_CODE TIME_SLOT
    CLOSH     12:00
    CLOSH     13:00
    CLOSH     14:00
    NOH       15:00
    NOH       16:00
    OPENH     09:00
    OPENH     10:00
    OPENH     11:00
    8 rows selected.Regards

  • Insert into Nested Tables

    Good day All,
    I am working on my first nested table and having difficulty with INSERTS. Can someone explain what I am doing wrong?
    Many Thanks,
    Danny
    describe PAT_HOST_SYSTEM
    Name Null Type
    HOST_ID NOT NULL NUMBER
    IPADDR NOT NULL VARCHAR2(16 CHAR)
    OS VARCHAR2(50 CHAR)
    OS_VERSION VARCHAR2(254 CHAR)
    KERNEL VARCHAR2(75 CHAR)
    KERNEL_BUILD VARCHAR2(75 CHAR)
    LAST_REBOOT VARCHAR2(50 CHAR)
    OS_PATCH VARCHAR2(50 CHAR)
    NUM_OF_CPU VARCHAR2(20 CHAR)
    GLOBAL_ZONE VARCHAR2(3)
    LOCAL_ZONE VARCHAR2(3)
    MACHINE VARCHAR2(255)
    UPTIME VARCHAR2(50)
    LAST_UPDATE DATE
    ZONE_CHILDREN LOCAL_ZONE()
    15 rows selected
    describe LOCAL_ZONE
    user type definition
    TYPE local_zone AS OBJECT
    (ID VARCHAR2(50),
    ZONE_NAME VARCHAR2(50));
    3 rows selected
    INSERT INTO TABLE (SELECT ZONE_CHILDREN FROM PAT_HOST_SYSTEM WHERE HOST_ID='561') VALUES ('a808d6ceee', 'tspxxx01');
    Error starting at line 1 in command:
    INSERT INTO TABLE (SELECT ZONE_CHILDREN FROM PAT_HOST_SYSTEM WHERE HOST_ID='561') VALUES ('a808d6ceee', 'tspxxx01')
    Error at Command Line:1 Column:12
    Error report:
    SQL Error: ORA-22905: cannot access rows from a non-nested table item
    22905. 00000 - "cannot access rows from a non-nested table item"
    *Cause:    attempt to access rows of an item whose type is not known at
    parse time or that is not of a nested table type
    *Action:   use CAST to cast the item to a nested table type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

    Hello Danny and welcome to the forum,
    are you trying to insert data into a table which has a collection as a column ?
    The phrase nested table was very misleading (at least for me), also the code you posted was kinda incomplete.
    I could not follow the code you posted, alternately I am posting some sample code with the DDL and insert statements for your understanding.
    create or replace type emp_obj as object
      ejob varchar2(100),
      comm number,
      edeptno number
    create table employee
    (ename varchar2(50),
    empno number,
    esal  number,
    edetails emp_obj
    /Populating the employee table with INSERT :
    insert into employee values ('KING',7839,5000,emp_obj('PRESIDENT',0,10));
    insert into employee values ('BLAKE',7698,2850,emp_obj('MANAGER',0,30));Now, querying the table for all columns with SELECT :
    ENAME     EMPNO     ESAL     EDETAILS.EJOB     EDETAILS.COMM     EDETAILS.EDEPTNO
    KING     7839     5000     PRESIDENT         0                 10
    BLAKE     7698     2850     MANAGER       0                 30Hope it is now clear.

  • Can't insert into nested table

    I can't inserted into a nested table and my SQL is listed below.
    SQL> CREATE TYPE naming_t AS OBJECT (name VARCHAR2(30), alias VARCHAR2(30)) NOT FINAL;
    2 /
    Type created.
    SQL> CREATE TYPE terminal_t;
    2 /
    Type created.
    SQL> CREATE TYPE terminal_t_nt AS TABLE OF REF terminal_t;
    2 /
    Type created.
    SQL> CREATE TYPE connectivitynode_t UNDER naming_t (terminals terminal_t_nt) NOT FINAL;
    2 /
    Type created.
    SQL> CREATE TYPE connectivitynode_t_nt AS TABLE OF REF connectivitynode_t;
    2 /
    Type created.
    SQL> CREATE TYPE terminal_t UNDER naming_t (connectivitynodes connectivitynode_t_nt) NOT FINAL;
    2 /
    Type created.
    SQL>
    SQL> CREATE TABLE naming_tb     (name VARCHAR2(30), alias VARCHAR2(30));
    Table created.
    SQL> CREATE TABLE connectivitynode_tb (name VARCHAR2(30), terminals terminal_t_nt) NESTED TABLE terminals STORE AS terminals_tb;
    Table created.
    SQL> CREATE TABLE terminal_tb     (name VARCHAR2(30), connectivitynodes connectivitynode_t_nt) NESTED TABLE connectivitynodes STORE AS connectivitynodes_tb;
    Table created.
    SQL>
    SQL> INSERT INTO naming_tb (name) VALUES ('AP1.132.B/C.T1');
    1 row created.
    SQL> INSERT INTO terminal_tb (name) VALUES ('AP1.132.B/C.T1');
    1 row created.
    SQL> INSERT INTO naming_tb (name) VALUES ('AP1.132.B/C.T2');
    1 row created.
    SQL> INSERT INTO terminal_tb (name) VALUES ('AP1.132.B/C.T2');
    1 row created.
    SQL>
    SQL> INSERT INTO naming_tb (name) VALUES ('AP1.132.B/C.N1');
    1 row created.
    SQL> INSERT INTO connectivitynode_tb (name) VALUES ('AP1.132.B/C.N1');
    1 row created.
    SQL> INSERT INTO TABLE (SELECT terminals FROM connectivitynode_tb WHERE name='AP1.132.B/C.N1') SELECT REF(p) FROM terminal WHERE p.name='AP1.132.B/C.T1' OR p.name='AP1.132.B/C.T2';
    INSERT INTO TABLE (SELECT terminals FROM connectivitynode_tb WHERE name='AP1.132.B/C.N1') SELECT REF(p) FROM terminal WHERE p.name='AP1.132.B/C.T1' OR p.name='AP1.132.B/C.T2'
    ERROR at line 1:
    ORA-00942: table or view does not exist

    I think you dont have the table terminal referred in following select statement
    SELECT REF(p) FROM terminal WHERE p.name='AP1.132.B/C.T1' OR p.name='AP1.132.B/C.T2';
    Chandar

  • How to find out inserts/updates on table through a query

    Hi All,
    I have huge collection if procedures in my database. when I check the table used by procedures, list appearing is also pretty big.
    Is there a way to find out the inserts/updates into the selected table?
    Please help me out!!!!!!
    Thanks in advance!!
    Regards,
    Srikanth

    SELECT owner, object_type, object_name, object_id, status
      FROM SYS.dba_objects
    WHERE object_id IN (
                       SELECT     object_id
                             FROM public_dependency
                       CONNECT BY PRIOR object_id = referenced_object_id
                       START WITH referenced_object_id =
                                                        (SELECT object_id
                                                           FROM SYS.dba_objects
                                                          WHERE owner = :owner AND object_name = :NAME
                                                                AND object_type = :TYPE))-- Mahesh Kaila

  • Insert/update multiple tables from one form.

    I'm working on an app. that requires the user to fill out a form. The contents from the form is then used to either insert new records or update existing records in multiple tables. Is that possible? Can someone give a details example?

    You should create a form like you would create it having one table. Use row_id as primary key. The rest of the process are done by the triggers - those will take care of updating the right table depending which column was hit.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Insert/Update related tables

    Hello,
    I am attempting to take XML data - and using a transform, map it to a DB Adapter "merge" (insert if new, update if not) on two related tables. I have set up my db tables as follows...
    Table A
    ID (unique, primary key)
    param1
    param2
    Table B
    ID (foreign key related to Table A - ID)
    paramA
    There is a "TableA 1:M Table B" relationship set up in the DB as well as in the DB adapter TopLink project.
    If I do an initial "merge" (insert), everything works fine - and I get my new record in Table A - and several new related records inserted into Table B (way cool!).
    However, if I then try to repeat the merge after modifying something in the incoming data that is associated with Table B data, Table B records associated with that ID all get set to the last instance of Table B data in the input. I know that's confusing - here's an example...
    Initial input:
    <CAR>
    <ID>7</ID>
    <param1>Chevrolet</param1>
    <param2>Corvette</param2>
    <paramA>T-top</paramA>
    <paramA>Mag Wheels</paramA>
    <paramA>Hood Scoop</paramA>
    </CAR>
    Resulting Table Data:
    Table A:
    ID param1 param2
    7 Chevrolet Corvette
    Table B:
    ID paramA
    7 T-top
    7 Mag Wheels
    7 Hood Scoop
    Second run with the following input:
    <CAR>
    <ID>7</ID>
    <param1>Chevrolet</param1>
    <param2>Corvette</param2>
    <paramA>T-top</paramA>
    <paramA>Mag Wheels</paramA>
    <paramA>Front Hood Scoop</paramA>
    </CAR>
    Resulting data in DB...
    Resulting Table Data:
    Table A:
    ID param1 param2
    7 Chevrolet Corvette
    Table B:
    ID paramA
    7 Front Hood Scoop
    7 Front Hood Scoop
    7 Front Hood Scoop
    I have verified that my XSL transform appears to be working correctly.
    Am I using the db adapter "merge" function for something it's not designed to handle (i.e. related tables)? Do I have to code separate update adapter instances to update my related tables individually? I hope not - I was hoping TopLink would just take care of this for me. Maybe I'm too optimistic... ;-)
    Thanks for any help!
    Lon

    Nevermind. I'm an idiot.
    Obviously, Table B needs another column to form a unique key - so an update can change just that row. Sorry for wasting your time. :(
    Lon

  • XSU bug? update nested tables

    crashed if locale RUSSIAN and update varchar2 contain simbols: " and :
    oracle.xml.sql.OracleXMLSQLException: Идентификатор привязки должен иметь ненулевую длину.     at oracle.xml.sql.core.OracleXMLConvert.getSchema(OracleXMLConvert.java:2885)     at oracle.xml.sql.query.OracleXMLQuery.getXMLSchema(OracleXMLQuery.java:539)
    JDK 1.4.1_01 latest XSU oracle 9.2 Win2k

    Would you send me the sample test case? We will fix it if it is a bug.

  • Inserting/updating XML output to tables

    Hi,
    I have a nested XML master details record(2 or 3 table). I want to breaking into different columns and insert/update corresponding table.
    How I parsed in XML.
    Thanks
    Reena

    You need to use extractValue() sql function

  • Insert / update data to a table through DBLINK (oracle)

    I try to insert / update a table from one instance of oracle database to another one through oracle dblink, get following error:
    java.sql.SQLException: ORA-01008: not all variables bound
    ORA-02063: preceding line from MYLINK
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
    The same code to insert / update the exact same table in local instance works fine.No any binding problem. So i am pretty sure all ? mark in SQL are set with some value before sending to Oracle.
    Someone please advise what is possible problem. Db link is not set correctly? or we can not update remote table by dblink.
    By the way i can do insert / update from TOAD to the remote table through DBLINK. Problem happens only in Java code.
    thanks!
    Gary

    dblink links from one database instance to another.
    So it is certainly a source of possible problems when it works on one database and not another.
    You should start by looking at the dblink and it possible testing it in the database not via java.
    Note as well that that error suggests that it is coming from the Oracle database. I believe if you had a bind parameter problem in your java code that the error would come from the driver. But that is a guess on my part.

  • How to insert reference of object in nested table

    hi , i have a problem with nested table :
    CREATE OR REPLACE TYPE ITEM AS OBJECT
    ITEM_ID NUMBER,
    ITEM_DES VARCHAR2(4000),
    PRODUCT_NO VARCHAR2(15),
    PRODUCT_DES VARCHAR2(4000)
    CREATE TABLE ITEMS OF ITEM
    CONSTRAINT ITEM_PK PRIMARY KEY (ITEM_ID)
    CREATE OR REPLACE TYPE BOM AS OBJECT
    BOM_ID NUMBER,
    ITEM_ID NUMBER,
    BOM_PARENT_ID number
    create or replace type boms as table of ref bom;
    create table bom_table
    bom_ids bom,bom_member boms
    ) nested table bom_member store as bom_childs;
    insert into bom_table (bom(1,1,null),null);
    insert into bom_table (bom(2,1,1),boms(select ref(t) from bom_table t where t.bom_id=1))
    show error.
    how i can insert in nested table reference of object
    thanks

    your table "bom_table" is not an object table or view, and thus you can't create object references to it's rows. you'll need to create an object table or view of "bom" objects, with a corresponding object identifier, and then reference that table/view in your subquery instead.
    Gerard

Maybe you are looking for

  • How can I locate a Scheduler job?

    Hi there, In the alert log, I see the following error : ORA-12012: error on auto execute of job 2915 My question is - how do I find the definition for job 2915? And before you say - "that's easy, it's in all_scheduler_jobs", it's not in all_scheduler

  • What happens when the Browser is Closed?

    Hi, Does anyone know for sure what happens to your CF template that is running on  the CF server when the browser is closed by the user.  Does the CFML continue to  be processed or is the template aborted? Suppose the user hit's submit to  a long run

  • E recruitment-Urgent Help

    Hi experts, My client wants E-REC to be implement,and im completely new to E-REC.I need help from all the experts as how to start E-REC Configuration and also please let me know the technical settings required here.And what is the role of Basis consu

  • How to update recovery partition from 10.8.2 to 10.8.3

    I recently update my MBP from 10.8.2 to 10.8.3.  I also use BootCamp to Windows 7.  When starting the MBP with holding alt/option button, it says that the recovery partition is still in 10.8.2.  How can I update the recovery to 10.8.3? Thanks in adva

  • What do I do about the file with a question mark when it starts up?

    I have a MacBook Pro, had it for 2 years now. It has been good, up until just now... It was on, perfect as normal until I plugged in my iPad mini and my iPod touch. It started freezing up, and so I turned it off, but when I turned it back on, the fil