Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 919695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:35:18+00:00 2026-05-15T18:35:18+00:00

I have an oracle table with nested tables in some of the columns. Now,

  • 0

I have an oracle table with nested tables in some of the columns. Now, I need to be able to update all the records in each nested table, in each of the records of the main table. How is this accomplished? Any of the ways that I’ve tried, I get errors about either not be able to perform updates on that view, or single row subquery returns more than one row.

here’s an example from to illustrate. I can run an update like this:

    UPDATE TABLE(select entity.name
                 from entity
                 where entity.uidn = 2)
    SET last = 'Decepticon',
    change_date = SYSDATE,
    change_user = USER
    WHERE first = 'Galvatron';

but in this case, the table clause is being executed on a single nested table from a single row. How would an update like this be performed if you didn’t want just the entity.uidn which equalled 2?

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:35:18+00:00Added an answer on May 15, 2026 at 6:35 pm

    Perhaps the best reason for avoiding nested tables in a database is that they are hard to work with, and the syntax is underdocumented and hard to grok.

    Moving on!

    Here is a table with a nested table.

    SQL> select f.force_name, t.id, t.name
      2  from transformer_forces f, table(f.force_members) t
      3  /
    
    FORCE_NAME         ID NAME
    ---------- ---------- --------------------
    Autobot             0 Metroplex
    Autobot             0 Optimus Prime
    Autobot             0 Rodimus
    Decepticon          0 Galvatron
    Decepticon          0 Megatron
    Decepticon          0 Starscream
    Dinobot             0 Grimlock
    Dinobot             0 Swoop
    Dinobot             0 Snarl
    
    9 rows selected.
    
    SQL>
    

    As you can see, each element in the nested table the ID attribute is set to zero in all cases. What we would like to do is update all of them. But, alas!

    SQL> update table
      2   ( select force_members from transformer_forces ) t
      3  set t.id = rownum
      4  /
     ( select force_members from transformer_forces ) t
       *
    ERROR at line 2:
    ORA-01427: single-row subquery returns more than one row
    
    
    SQL> 
    

    It is possible to update all the elements on a nested table for a single row in the holding table:

    SQL> update table
      2       ( select force_members from transformer_forces
      3         where force_name = 'Autobot') t
      4      set t.id = rownum
      5  /
    
    3 rows updated.
    
    SQL>
    

    But the only way of doing that for the whole table is a PL/SQL loop. Yuck!

    There is an alternative: use a Nested Table Locator, via the NESTED_TABLE_GET_REFS hint. This is a particularly obscure thing (it’s not in the main list of hints) but it does the trick:

    SQL> update /*+ NESTED_TABLE_GET_REFS */ force_members_nt
      2  set id = rownum
      3  /
    
    9 rows updated.
    
    SQL> select f.force_name, t.id, t.name
      2  from transformer_forces f, table(f.force_members) t
      3  /
    
    FORCE_NAME         ID NAME
    ---------- ---------- --------------------
    Autobot             1 Metroplex
    Autobot             2 Optimus Prime
    Autobot             3 Rodimus
    Decepticon          4 Galvatron
    Decepticon          5 Megatron
    Decepticon          6 Starscream
    Dinobot             7 Grimlock
    Dinobot             8 Swoop
    Dinobot             9 Snarl
    
    9 rows selected.
    
    SQL>
    

    This hint allows us to bypass the holding table altogether and work with the actual nested table. That is, the object specified in the Nested Table storage clause:

    create table transformer_forces (
        force_name varchar2(10)
        , force_members transformers_nt)
    nested table force_members store as force_members_nt return as value;
                                        ^^^^^^^^^^^^^^^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have oracle table that holds more than 30 million records, I need to
I have an Oracle table dump containing insert statements. Some of the tables contain
I have an oracle 10g database that has 2 tables: a REBATES table, and
I have an application that records activity in a table (Oracle 10g). The logging
I have two columns(column1, column2) in my oracle database table named as demo .
I have an Oracle table 12K records/gyms, and the query below takes approximately ~0.3s:
I have an Oracle data table fetching columns that be null. So I figure
I have an HTML page that has many nested tables, for example table for
I have an Oracle table which has a name,value,time columns.Basically the table is for
Suppose I have an oracle table with two columns: type varchar2 and data varchar2.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.