Sort Field Values

Question

I have a table name orders which consists of six columns:
num1 number, num2 number , num3 number , num4 number , num5 number , num6 number
There is a routine which fills data in this table, but the order of the inserted data is casual.
My requirement is to create a view over this table in an organized manner.
Say this is a row in the table:
num1 ,num2 , num3 , num4, num5 , num6
------------------------------------------------------------------------
2 7 38 8 19 49
I need to order values in this row in ascending order in the way data in the view is ordered, so the data should appear in the view in the following way:
num1 ,num2 , num3 , num4 , num5 , num6
-------------------------------------------------------------------- 
2 7 8 19 38 49

Could anyone please suggest a way to accomplish this?

 

Answer

It’s not convenient to achieve your requirement in SQL. So let’s retrieve data out to be processed in SPL (Structured Process Language). Here’s the SPL script:

A

1

$select * from orders

2

=A1.(~.record(~.array().sort()))

A1: Retrieve data from orders.

A2: array() function joins field values in A1’s each record into a sequence; sort() function orders each sequence in ascending order; record() function populates every member in each sequence to A1’s corresponding record.

You can call the SPL script in a third application. About the details, refer to How to Call an SPL Script in Java.