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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:10:50+00:00 2026-05-17T23:10:50+00:00

okay, I am beating myself up over this. I am need to load a

  • 0

okay, I am beating myself up over this. I am need to load a array in people last name stored in a table. Then sort the last names and print them out in alphabetical order. This must be done using the bubble sort algorithm.

here is what I have so far

CREATE OR REPLACE PROCEDURE TEAM_TABLE_SORT AS
  TYPE player_Name_type IS TABLE OF databasename.team.player%type
  INDEX BY PLS_INTEGER ;
  player_name player_Name_type;
  i integer := 1;
  temp integer;

BEGIN

  FOR player_names IN (SELECT * FROM marshall.team )
  LOOP
    player_name(i) := player_names.player;
    DBMS_OUTPUT.PUT_LINE(i|| ' - ' ||chr(9) || player_name(i) ) ;
    i := i + 1 ;
  END LOOP

All this really does is print out the names. I cannot get it to sort. I am not try thing this

TYPE player_Name_type IS TABLE OF  %type INDEX BY varchar2(20) ;
aux player_Name_type;
i integer := 1;
v_current is table of aux
swapped BOOLEAN := TRUE;

BEGIN

  FOR aux IN (SELECT * FROM )
  LOOP
    DBMS_OUTPUT.PUT_LINE(i|| ' - ' ||chr(9) || aux.player);
    i := i + 1 ;
  END LOOP;

  v_current := aux.first;
  WHILE(swapped)
  LOOP
    swapped := FALSE;

    FOR I IN 1..(aux.count-2) LOOP
      IF aux(i) > aux(I+1) THEN
         v_current := aux(i+1);
         aux(I+1) := aux(i);
         aux(i) :=  v_current;
      END IF;
      swapped := TRUE;

    END LOOP;

  END LOOP;

FOR aux IN (SELECT * FROM    LOOP

  DBMS_OUTPUT.PUT_LINE(i|| ' - ' ||chr(9) ||aux.player);
  i := i + 1 ;
END LOOP;
  • 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-17T23:10:51+00:00Added an answer on May 17, 2026 at 11:10 pm

    This should be what you are looking for. Note that it is better to type the variables/collections off of the tables like you have in your example. I just used generic versions since I don’t have your tables to work with. If you don’t understand how this is working, feel free to ask. I am guessing this is homework (who else would bubble sort in Oracle), so the point of the assignment is for you to understand it, not just to get it right. 🙂

    DECLARE
      coll    DBMS_SQL.VARCHAR2A;
      swapped BOOLEAN;
      tmp     VARCHAR2(10);
    BEGIN
      /*
        Generate 10 random strings and collect them into our collection
        Note: you would replace this with your query on marshall.team
      */
      select dbms_random.string('l',10) rand_string
      BULK COLLECT INTO coll
      from dual
      connect by level <= 10;
    
    
      /*
        At this point, all of the rows we need are in our collection
        so there is no need to go back to the table anymore.  Now onto the...
    
        Bubble sort.. walk through the collection swapping elements until
        we make a pass where no swapping takes place
      */
      LOOP
    
       swapped := false;
    
       FOR i IN 2 .. coll.LAST
       LOOP
    
         IF coll(i-1) > coll(i)
         THEN
           -- swap records
           tmp := coll(i);
           coll(i) := coll(i-1);
           coll(i-1) := tmp;
    
           /*
             Mark that swap has taken place.  note we mark as true only inside
             the if block, meaning a swap really did take place
           */ 
           swapped := true;
    
          END IF;
    
       END LOOP;
    
       -- If we passed through table without swapping we are done, so exit
       EXIT WHEN NOT swapped;
    
      END LOOP; 
    
      /*
        Now print out records to make sure they are in order.  Again notice
        how we are just referencing the (now sorted) collection and not going
        back to the table again
      */
      FOR i in coll.FIRST .. coll.LAST
      LOOP
    
        dbms_output.put_line(coll(i));
    
      END LOOP;
    
    END;
    /
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I have spent the last 2 days trying to sort this one out.
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay, so this seems simple, but I can't think of a straightforward solution; Basically
Okay, I feel like I should be able to do this, but I have
Okay so this has been modified there is still 3 tables board, account, log
Okay, none of the previous questions I have seen with this error seem to
Okay, so this is a long long shot but here it goes... When IE
Okay so my question is this. Say I have a simple C++ code: #include
Okay, this one is pretty obvious to everyone who use Django and frequently asked
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But

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.