Home » Developer & Programmer » Forms » Record Group values in Order
Record Group values in Order [message #82147] Tue, 29 April 2003 01:18 Go to next message
nelson
Messages: 30
Registered: February 2000
Member
Hi folks,
I'm having one serious problem in Record Group.
a Record group having mulple records in random order.
I want to fetch records from Record group in order.
Does it possible?
I want to fetch the records from Record group by order.
Re: Record Group values in Order [message #82149 is a reply to message #82147] Tue, 29 April 2003 02:58 Go to previous messageGo to next message
Muzzammil
Messages: 99
Registered: February 2003
Member
Go to Record Group Properties.

In Record Group Query Select Statemnt add Order by ASC

SELECT ALL A.NAME,A.DESIGNATION,A.SALARY
FROM A
ORDER BY A.NAME ASC
Re: Record Group values in Order [message #82151 is a reply to message #82149] Tue, 29 April 2003 03:52 Go to previous messageGo to next message
nelson
Messages: 30
Registered: February 2000
Member
Hi Muzzammil,
I think u got wrong information.
I have created a Record group dynamically from lot of static & Computed values. I want to fetch the records from a Record group in Ascending/Descending order.
I can't go by Order by Calues. So is there any other solution.
Thanks
Candy
Re: Record Group values in Order [message #82152 is a reply to message #82151] Tue, 29 April 2003 04:30 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Can't you add an 'ORDER BY 1' clause? You know most probably whether you want to sort by column 1 or 2 or ... . This is used in our app too whenever we use a POPULATE_GROUP_WITH_QUERY built-in.

MHE
Re: Record Group values in Order [message #82153 is a reply to message #82152] Tue, 29 April 2003 06:10 Go to previous messageGo to next message
nelson
Messages: 30
Registered: February 2000
Member
Hi Maaher,
This is my thing,
1. I have created one Dynamic Record Group 'RG' with one column named Val(This is not from database or Table)
2. I am inserting values in randam order(Based on some computing values).
3. I want to fetch this random values in either ascending/Descending order

I cant use order by 1- Because i have created record group which is not from database or Table.

In the same manner, i cant go with POPULATE_GROUP_WITH_QUERY-Builtin

So is there any other way?

Thanks in Advance

Candy
Re: Record Group values in Order [message #82158 is a reply to message #82153] Wed, 30 April 2003 00:49 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Well,
Can't you select from DUAL? Using UNIONs for each value. You can concatenate for each value and then in the end, add the ORDER BY clause. Look at my (quick and dirty) example. You can run it in SQL*Plus to see the outcome. Play with the ORDER BY (ASC/DESC) to be sure:
----------------------------------------------------------------------
  1  DECLARE
  2    TYPE v_ref_type IS REF CURSOR;
  3    v_cur v_ref_type;
  4    TYPE v_tab_type IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER;
  5    v_tab v_tab_type;
  6    v_query_string VARCHAR2(2000);
  7    j NUMBER := 0;
  8  begin
  9  -- Building the SQL string using unions
 10    v_query_string := 'SELECT ''xx'' val FROM DUAL';
 11    FOR i IN 1..10 LOOP
 12      -- Inserting some dummy values. At loop numer 8, insert a calculated value
 13      -- namely: 72 (80-8)
 14      IF i = 8 THEN
 15        v_query_string := v_query_string||' UNION SELECT to_char('||(i*10-i)||') val FROM DUAL';
 16      ELSE
 17        v_query_string := v_query_string||' UNION SELECT '''||chr(65+i)||'Y'' val FROM DUAL';
 18      END IF;
 19    END LOOP;
 20  -- In the end, add the ORDER BY
 21    v_query_string := v_query_string||' ORDER BY 1 ASC';
 22  -- Open a cursor using the SQL string we just built
 23    OPEN v_cur for v_query_string;
 24    LOOP
 25      j := j+1;
 26      FETCH v_cur INTO v_tab(j);
 27      EXIT WHEN v_cur%NOTFOUND;
 28    END LOOP;
 29    CLOSE v_cur;
 30    FOR  a IN 1..v_tab.COUNT LOOP
 31       dbms_output.put_line(v_tab(a)||' is element '||a);
 32    END LOOP;
 33  EXCEPTION
 34    WHEN OTHERS THEN
 35      dbms_output.put_line('Error: '||sqlerrm);
 36      IF v_cur%ISOPEN THEN
 37        CLOSE v_cur;
 38      END IF;
 39* END;
SQL> /
72 is element 1
BY is element 2
CY is element 3
DY is element 4
EY is element 5
FY is element 6
GY is element 7
HY is element 8
JY is element 9
KY is element 10
xx is element 11

PL/SQL procedure successfully completed.

SQL> 

----------------------------------------------------------------------
HTH,
MHE
Previous Topic: Very Urgent Help needed - Arabic support in Forms6i& reports6i
Next Topic: HOST command and OS User
Goto Forum:
  


Current Time: Fri Apr 19 22:34:18 CDT 2024