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 9151423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:47:54+00:00 2026-06-17T11:47:54+00:00

What is the diffecence between adding INDEX BY PLS_INTEGER and not at end of

  • 0

What is the diffecence between adding INDEX BY PLS_INTEGER and not at end of declaration of new table type. Look at this example:

DECLARE
    GC_BULK_LIMIT CONSTANT INTEGER := 500;
    CURSOR CUR_CLIENTS IS SELECT C.ID, C.NAME FROM CLIENTS C;
    TYPE RT_CLIENTS IS TABLE OF CUR_CLIENTS%ROWTYPE;
    -- TYPE RT_CLIENTS IS TABLE OF CUR_CLIENTS%ROWTYPE INDEX BY PLS_INTEGER;
    LT_CLIENTS RT_CLIENTS;
BEGIN
    OPEN CUR_CLIENTS;
    LOOP
        FETCH CUR_CLIENTS BULK COLLECT INTO LT_CLIENTS LIMIT GC_BULK_LIMIT;
        EXIT WHEN LT_CLIENTS.COUNT = 0;
        FOR I IN 1..LT_CLIENTS.COUNT LOOP
            -- ... SOME LOGIC
        END LOOP;
    END LOOP;
    CLOSE CUR_CLIENTS;
END;
  • 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-06-17T11:47:55+00:00Added an answer on June 17, 2026 at 11:47 am

    in response to “must i add”. The short answer is NO.

    the difference is that

    TYPE RT_CLIENTS IS TABLE OF CUR_CLIENTS%ROWTYPE;
    

    Is a nested table. This means that for a given variable of this type, we know that the subscripts are sequential. i.e. the subscript starts from 1 and goes up to the array length.

    The following loop therefore, is the right way to access a nested table array:

    FOR I IN 1..LT_CLIENTS.COUNT LOOP
    

    This however, is called a associative array:

    TYPE RT_CLIENTS IS TABLE OF CUR_CLIENTS%ROWTYPE INDEX BY PLS_INTEGER;
    

    (you could also index by a varchar2 if you wanted). The difference is that the subscripts in this case do not have to be sequential, depending on how the array was populated. In your code, they would be (as bulk collect would do that), but its not always the case.

    The safe way to access and loop through an index by array is :

      v_subscript := t_arr.first;
      while v_subscript is not null loop
        dbms_output.put_line(v_subscript || ': ' || t_arr(v_subscript));
        v_subscript := t_arr.next(v_subscript); 
      end loop;
    

    where v_subscript is a variable of the same datatype of the index by part.

    also with a nested table, you can populate the array quickly with:

    declare
      type myarr is table of number;
      t_arr         myarr;
        v_subscript   number;
    begin
      t_arr := myarr(1, 12, 44);
    

    whereas with an index by array you’d have to have three lines there to populate it:

      t_arr(1):= 1;
      t_arr(2):= 12;
      t_arr(3):= 44;
    

    for your particular case, without the index by is perfectly fine.

    further reading: http://docs.oracle.com/cd/E18283_01/appdev.112/e17126/composites.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problems with adding values to dates and also getting differences between
Is there a difference between this.form and document.forms (document[forms]) or, are they similar? Here
Adding a seemingly perfectly index is having an unexpectedly adverse affect on a query
What's the difference between adding bin , bin/ , bin/* and bin/** in my
What is the difference between adding the subview to self and or to the
What is the difference between adding a reference to Excel 11.0 from .NET vs
Possible Duplicate: difference between throw and throw new Exception() I'm a programmer working on
What is difference between adding external jar and using library project in android? can
I'm not sure what the difference between these two pieces of code is (with
What is the difference between adding a dependency jar to the .classpath file in

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.