Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
implement the bubble sort algorithm by using the PL/SQL stored procedures.

Below is the table structure that should be used;


CREATE TABLE TBL( POSITION INTEGER,
VAL INTEGER,

CONSTRAINT PK PRIMARY KEY (POSITION)
);

INSERT INTO TBL VALUES (1, 5);
INSERT INTO TBL VALUES (2, 1);
INSERT INTO TBL VALUES (3, 4);
INSERT INTO TBL VALUES (4, 2);
INSERT INTO TBL VALUES (5, 8);


After the sorting, the results in table should be something like this.

SELET * FROM TBL

POSITION VAL
--------------- ------
1 1
2 2
3 4
4 5
5 8


Important Notes:
** The column named POSITION will always have sequential values starting from 1. There are no missing values in the sequence, so you can use the values in this column while fetching the values and comparing them.


please help me doing that
m noob in pl sql
Posted
Comments
Maciej Los 26-Nov-14 5:51am    
Not a question at all!
Tomas Takac 26-Nov-14 5:53am    
Can I ask what is this good for?
Tomas Takac 26-Nov-14 5:57am    
BTW somebody asked a very similar question yesterday: How can we bubble sort a table data in PL/SQL?[^]
Mohsin Mustufa 26-Nov-14 6:28am    
this is an assignment and i have no idea
Tomas Takac 26-Nov-14 6:51am    
Shouldn't you then study more to learn pl/sql? I suggest you get your requirements straight. Programming bubble sort in database makes no sense at all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900