Output not sorted when using group by clause

Recently we migrated our application from Forms5 to Forms10g and database from 7.3.2 to 10gR2.
More than 400 applications using sql stmt with "group by" clause and without "order by".
In Earlier version of oracle 7.3.2 "group by" clause in SQL stmt sorts the output by order of the column in the "group by"
stmt, where new version of oracle 10g (10.2.0.1.0 - 64bit Production) doesnt behave like older version.
eg select div_cd,dept_cd,count(*) from class group by div_cd,dept_cd
Output of the above query in Oracle7
DIV_CD DEPT_CD COUNT(*)
0 1     120
0 9 131
1 4 938
1 6 1
4 1 1490
5 2 59
6 6 848
6 9 295
8 1 45
9 5 19
Output of same query in Oracle10g
DIV_CD DEPT_CD COUNT(*)
0 6 120
0 9 131
4 1 1490
6 9 295
8 1 45
9 5 19
1 4 938
1 6 1
5 2 59
6 6 848
My question is
a) Does the oracle behave in that manner?.
b) if so, Any patch set available for this?
c) if no patch set how to resolve this issue.
if i use "order by" clause
along with group by then i can get the output how i want.
BUt problem is more than 400 applications (forms) using above method.
Identify Forms/Reports and rectifing is a tedious job.
Anyone can give me a good solution to solve the above issue

Group By does not, and never has guaranteed order. Just because it happened that way on the past does not mean it will continue to do so.
In the past, the algorithm used for Group By invoked a sort. It was convenient for the system to simply dump the output in that resulting order. These days, Group By could also be accomplished using a hash algorithm. Walking through the hash can easily result in a completely different ordering, as you have seen.
Your problem is that the assumptions made previously are now invalid. Oracle is still working correctly. No patch, but you might be able to work around it by crippling your database and using the COMPATIBLE parameter (although the official lower limit is 9.2.0)

Similar Messages

  • ORA-00907: missing right parenthesis when using group by clause with xmlagg

    I have the following query and I am getting ORA 00907 Error when I am using group by clause with the xmlagg function.
    select xmlelement("Mitigation",
                    xmlelement("m_szMethodName",tm.DisplayName),
                    xmlelement("SubstanceInterferenceProtocolList",
                                (select xmlagg(xmlelement("MitigationProtocol",
                                        xmlelement("m_szMethodName",tm.DisplayName),
                                        xmlelement("m_szInterferenceProtocolName",tmp.protocol_name),
                                        xmlelement("m_szInterferenceSubstance",tmp.intf_mtrl_prod_code),
                                        xmlelement("m_ProtocolParameters",
                                            xmlelement("m_szProtocolName",tmp.protocol_name),
                                                xmlelement("m_Consumables",
                                                    xmlelement("Consumable",
                                                        xmlelement("m_szConsumId", xrl.rgnt_pack_name),
                                                        xmlelement("m_szProductCode",xrl.pack_prod_code),
                                                        xmlelement("m_nVolume",tmp.fluid_vol),
                                                        xmlelement("m_szProtocolStep",xps.protocol_step_name))),
                                                    xmlelement("m_ProtParamList",
                                                        xmlagg(
                                                        xmlelement("ParameterValues",
                                                            xmlelement("m_szProtocolName",tmp.protocol_name),
                                                            xmlelement("m_Time",xpsd.parameter_ntime_value))
                                                        group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)
                    order by tmp.ccd_test_id, tmp.intf_mtrl_prod_code, xps.protocol_step_intprotocolstep )
                    from XPR_tdef_mitigation_protocol tmp, xp_reagentlist xrl,
                    xpr_protocol_settings xps, xpr_protocol_settings_default xpsd
                    where tmp.ccd_test_id = tm.ccd_test_id
                    and tmp.ccd_test_id = xrl.ccd_test_id
                    and tmp.pack_prod_code = xrl.pack_prod_code
                    and tmp.intf_type = 1
                    and xps.protocol_name = xpsd.protocol_name
                    and xps.protocol_step_name = xpsd.protocol_step_name
                    and xps.ps_action_parameterlist = xpsd.ps_action_parameterlist
                    and xps.protocol_name =  tmp.PROTOCOL_NAME
    from XPtoXPRTdef_defn_mapping tm
    where tm.DisplayName = 'SYPH'If I remove the xmlagg clause along with the group by clause, the query runs fine and give me the output.
    But in that XML format of the output is incorrect for my application.
    Could someone help here?

    Hi,
    userAtoZ wrote:
    I have the following query and I am getting ORA 00907 Error when I am using group by clause with the xmlagg function.
    ... xmlagg(
    xmlelement("ParameterValues",
    xmlelement("m_szProtocolName",tmp.protocol_name),
    xmlelement("m_Time",xpsd.parameter_ntime_value))
    group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)Please don't post unformatted code. When posting any formatted text on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    If the code above were formatted well, so that you could match each '(' with its closing ')', it would look something like this:... xmlagg ( xmlelement ( "ParameterValues"
                        , xmlelement ( "m_szProtocolName"
                                       , tmp.protocol_name
                        , xmlelement ( "m_Time"
                                       , xpsd.parameter_ntime_value
    group by tmp.ccd_test_id
                        ,     tmp.intf_mtrl_prod_code
    This is exactly what you posted, only the whitespace has been changed.
    This makes it clear that the GROUP BY is inside the parentheses with the argument to XMLAGG.  You can have an ORDER BY clause there, but not a GROUP BY clause.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using indexes when using group by clause

    How can I make use of indexes when there is a group by clause in the sql/ pl/sql. Heard that when ever there is a group by clause , sql bypasses use of indexes. Is it true?
    Thanks in advance

    Hi,
    Depending on the query containing the group by, indexes will still be used.
    For example, create a big table based on the all_objects table. Then create an index on the object_type column. Then run this query:
    select count(*), object_type from big_table where object_type != 'PACKAGE' group by object_type
    The execution plan for this query will show the index to be used, the group by does not prevent the optimizer from using an index. Then run this query:
    select count(*), object_type from big_table group by object_type
    The execution plan for this query will show the index not to be used because the whole table - no restrictions - needs to be read to get the result.
    Hope this helps!
    Regards,
    Marco Stuijvenberg
    =
    www.marcostuijvenberg.nl

  • Output not appearing when using SwingWorker?

    Hi guys,
    I'm desperate here. Any help would be great.
    I'm using SwingWorker to append info into a Text Area, but when I run the code, nothing happens in the TextArea. Here's the code
    public class RLGUIFrame extends javax.swing.JFrame implements ActionListener{
        private final GridBagConstraints constraints;
        JTextArea movementText;
        private final Border border =
            BorderFactory.createLoweredBevelBorder();
        private final JButton startButton, stopButton;
        private RobotTask robTask;
         public static final int GRID_SIZE=10;
         public static final int NUMBER_OF_TIMES=1000;
        private JTextArea makeText() {
            JTextArea t = new JTextArea();
            t.setEditable(false);
            t.setAlignmentX(RIGHT_ALIGNMENT);
            t.setBorder(border);
            getContentPane().add(t, constraints);
            return t;
        private JButton makeButton(String caption) {
            JButton b = new JButton(caption);
            b.setActionCommand(caption);
            b.addActionListener(this);
            getContentPane().add(b, constraints);
            return b;
        public RLGUIFrame() {
            super("RL");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Make text boxes
            getContentPane().setLayout(new GridBagLayout());
            constraints = new GridBagConstraints();
            constraints.insets = new Insets(3, 10, 3, 10);
            movementText = makeText();
            //Make buttons
            startButton = makeButton("Start");
            stopButton = makeButton("Stop");
            stopButton.setEnabled(false);
            //Display the window.
            pack();
            setVisible(true);
        private class LocReport{
             private Location loc;
             private double val, rand;
             private boolean KS;
             LocReport(Location L, double value, boolean KillSpot, double random){
                  this.loc = L;
                  this.val = value;
                  this.KS = KillSpot;
                  this.rand = random;
    private class RobotTask extends SwingWorker<Void, LocReport> {
        @Override
        protected Void doInBackground() {
            Grid grid = new Grid( GRID_SIZE );
             Location startPosition = grid.getLoc( 8, 8 );
             Robot jerry = new Robot( startPosition );
             Random rand = new Random();
             grid.fillGrid();
            //EastWestSentry ews = new EastWestSentry( grid.getLoc(5, 5));
             grid.getLoc( 3 , 3 ).setValue( 1.0 );
             grid.getLoc( 7 , 7 ).setValue( 0.0 );
             for( int i = 0; i < GRID_SIZE; i++){
                  grid.getLoc( i, 4 ).isKillSpot = true;
             grid.getLoc(4, 5).isWindy    = true;
             grid.getLoc(7, 5).isKillSpot = true;
             grid.getLoc( 6, 4 ).isKillSpot = false;
             for( int i=0; i < NUMBER_OF_TIMES; i++ ){
             while ( jerry.getLocation() != grid.getLoc( 3 , 3 ) ){
             Location L = jerry.getLocation();
             double value = L.value;
             double random = rand.nextDouble();
             boolean isKS = L.KillSpot();
             publish( new LocReport(L,value,isKS,random) );
              if(jerry.getLocation().isWindy == true)
                   jerry.move( grid.getLoc(7, 5) );
              if( jerry.getLocation().hasSentry )
                        jerry.getLocation().isKillSpot = true;     
              if(jerry.getLocation().isKillSpot == true){
                   if( rand.nextDouble() > 0.5 ){
                        System.out.printf("Lucky this time. This killspot didn't kill me.\n");
                   }else{
                   grid.getLoc(jerry.getXCoord(), jerry.getYCoord()).setValue(-1);
                   jerry.regenerate( startPosition );
              if(rand.nextDouble()>0.8){
                   System.out.printf("I'm going exploring!\n");
                   jerry.exploratoryMove();
              else{
                   //ews.patrol();
                   jerry.move();
                   if( jerry.getMyPreviousLocation().isKillSpot &&
                        jerry.getMyPreviousLocation().getValue() > 0.0 ){
                        jerry.getMyPreviousLocation().setValue(-1);
             return null;
        protected void process(List<LocReport> locs) {
             LocReport location = locs.get( locs.size() - 1);
             movementText.append("========================\n");
             movementText.append("Robot is at location : " + location.loc.getXCoord() +
                                   ", " + location.loc.getYCoord() + "\n");
             movementText.append("It's value is : " + location.val + "\n");
    public void actionPerformed(ActionEvent e) {
        if ("Start" == e.getActionCommand()) {
            startButton.setEnabled(false);
            stopButton.setEnabled(true);
            (robTask = new RobotTask()).execute();
        } else if ("Stop" == e.getActionCommand()) {
            startButton.setEnabled(true);
            stopButton.setEnabled(false);
            robTask.cancel(true);
            robTask = null;
        * @param args the command line arguments
        public static void main(String args[]) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new RLGUIFrame();
    }Edited by: zimmerPlease on Mar 23, 2010 3:58 PM

    You're adding both components with the same GridBagConstraints without setting any of its attributes. Follow the link to the Swing tutorial efrom the topic listing page for this forum and click through to the Layouts section where you can learn how to use GridBagLayout and GridBagConstraints properly.
    As an aside, there is no need to extend JFrame to create a GUI that has to show a JFrame. Favor composition over inheritance. And in this case, it leads to add(...) coode being all over the place where it can't be easily found.
    db

  • How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    Create a group and send mail
    http://www.dummies.com/how-to/content/how-to-create-a-basic-contact-group-in-mac -os-x-li.html
    http://www.macworld.com/article/1165582/how_to_email_groups_with_mail.html
    Best.

  • How to write a SQL Query without using group by clause

    Hi,
    Can anyone help me to find out if there is a approach to build a SQL Query without using group by clause.
    Please site an example if is it so,
    Regards

    I hope this example could illuminate danepc on is problem.
    CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
    CREATE OR REPLACE FUNCTION GET_ARR return my_array
    as
         arr my_array;
    begin
         arr := my_array();
         for i in 1..10 loop
              arr.extend;
              arr(i) := i mod 7;
         end loop;
         return arr;
    end;
    select column_value
    from table(get_arr)
    order by column_value;
    select column_value,count(*) occurences
    from table(get_arr)
    group by column_value
    order by column_value;And the output should be something like this:
    SQL> CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
      2  /
    Tipo creato.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION GET_ARR return my_array
      2  as
      3   arr my_array;
      4  begin
      5   arr := my_array();
      6   for i in 1..10 loop
      7    arr.extend;
      8    arr(i) := i mod 7;
      9   end loop;
    10   return arr;
    11  end;
    12  /
    Funzione creata.
    SQL>
    SQL>
    SQL> select column_value
      2  from table(get_arr)
      3  order by column_value;
    COLUMN_VALUE
               0
               1
               1
               2
               2
               3
               3
               4
               5
               6
    Selezionate 10 righe.
    SQL>
    SQL> select column_value,count(*) occurences
      2  from table(get_arr)
      3  group by column_value
      4  order by column_value;
    COLUMN_VALUE OCCURENCES
               0          1
               1          2
               2          2
               3          2
               4          1
               5          1
               6          1
    Selezionate 7 righe.
    SQL> Bye Alessandro

  • Images on Facebook do not appear when using different web browsers

    Images on Facebook do not appear when using Safari on my Macbook Pro (I've tried Google Chrome too with the same result).  This makes me think it's a setting within OS Mavericks that I'm missing.  I have not seen this issue on any other computers.  This only occurs on my, and others' profile pictures on my profile page and on the news feed, not photos that are posted in albums or on walls.  and yes, i have images enabled in Safari.
    In safari the images don't appear, and in their place is a small blue "?" square >>.
    In Chrome it appears as a broken image link >>
    Has anyone encountered this?  Is there a fix?  It is very annoying.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, or by corruption of certain system caches. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and  Wi-Fi on certain models. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • The volume up and down controls on my wireless keyboard show a no entry sign and do not respond when used...please help?

    The volume up and down controls on my wireless keyboard show a no entry sign and do not respond when used...please help?

    If you want to get a little more "exotic" you can try remapping the function keys.  I did a little google searching and the hits that looked promising are,
    Mapping volume and eject keys to 3rd-party keyboard Other Hardware
    Spark
    Spark is a powerful, and easy Shortcuts manager. With Spark you can create Hot Keys to launch applications and documents, execute AppleScript, control iTunes, and more...
    You can also export and import your Hot Keys library, or save it in HTML format to print it.
    Spark is free, so use it without moderation!

  • How can i set songs within a playlist, or an entire playlist, so that they are not included when using the shuffle function on IPOD Classic? Is this possible?

    How can i set songs within a playlist, or an entire playlist, so that they are not included when using the shuffle function on IPOD Classic?
    Is this possible?

    You can set any song to Skip when shuffling.
    In your iTunes Library, highlight the song and right-click/Get Info. On the Options tab is the Skip when shuffling box. Select that and then Sync the iPod with your Library.

  • Module borders not displaying when using Aggregator

    I am using Captivate 4.  I created a TOC for both modules in a project. Then I created an Aggregator to connect them and display both TOCs.
    The issue I am havving is that the individual modules have borders on all 4 sides, yet they do not display when using the aggregator. How do I correct this?
    Thank you.

    Lenny,
    I apologize for not having an answer to your question, but I'm envious that you've successfully configured mod_jk. I've read several different versions of how to configure this, but nothing has worked so far. I wonder if you could either point me to some correct instructions on how to integrate Apache and Tomcat so I might try to duplicate your success.
    Thanks in advance,
    Vince

  • U/tube videos open when using Safari but will not open when using Firefox.

    u/tube videos open fine when using Safari but will not open when using Firefox. With Firefox I get the unhighlighted Quicktime symbol with a question mark in the center. WHY?? Any help appreciated --- Toroya

    Hmmmm, strange you view YouTube in Safari & not FF. Which version of FF are you using?
    Try the following:
    Repair permissions & restart.
    Make sure you have the latest versions of Adobe Flash Player Software
    QuickTime Preferences > Advanced > MIME Stettings > Miscellaneous.
    Deactivate the "Flash Media" option.

  • Look for a progarm that will let me have 2 moniters but one will lock on and will not change when using spaces

    look for a progarm that will let me have 2 moniters but one will lock on and will not change when using spaces

    ok so i have one moniter to the right of me and i want to keep my google chrome on that one but still be abel to use space on the many monter. cuz when you go to spaces it movies both moniter i hope that help and i hope that you can help me.

  • Photoshop CC. Colour selection not working when using alt and brush.

    Hi, Photoshop CC. Windows 8.1 64 bit. Colour selection not working when using alt and brush. I have tried rebooting and other things like closing swatch panel etc.
    The alt key is otherwise OK.  It's not the recent upgrade from Win 8 to 8.1 (5 days ago) because the colour selection facility was working yesterday. Any ideas.

    I'd say things sound desperate enough to try resetting Preferences
    Reset Preferences
    Windows — Hold down Shift Ctrl Alt immediately after starting Photoshop
    Mac — Hold down Shift Cmd Opt immediately after starting Photoshop
    If that fails, we need to know your operating system?
    Do you have a full CC subscription, or by apps do you mean Photoshop, Bridge and Lightroom?
    Another other information that might pertain ?

  • Serial number not  accepted when using disc to download on second computer.

    Serial number not accepted when using disc ot download CS6 to second computer. Help...

    make sure you're entering the correct serial number for the correct product:  http://helpx.adobe.com/x-productkb/global/find-serial-number.html
    if you're certain that you are doing that, contact adobe support:  http://www.adobe.com/support/chat/ivrchat.html

  • Siri does not work when used for calling a contact function

    Siri does not work when used for calling a contact function

    Very strange, try to turn off/on your iPhone. Or make a reset (home+power button)...
    If it continues try to restore it.

Maybe you are looking for

  • A lot of memory is used when multiple tabs are open

    Is there anything that can be done about the insane memory usage in Firefox when multiple tabs are open? I often have 20+ tabs open and the amount of RAM that Firefox uses when I have it open with this many tabs is just ridiculous. As an example of t

  • How do I get a purchased ringtone from my music library to Ringtones?

    I've purchased a couple of ringtones from itunes but they downloaded into my music library and I can't figure out how to move them to the Ringtones folder in my library. I tried going back to itunes and downloading them directly onto my phone but the

  • How do i get my music from my phone onto my itunes on a computer?

    How do i get my music from my iphone onto my itunes on a computer?

  • I want to lean webdynpro

    Hi All, I have  only one year experience in ABAP. and i want ot learn Webdynpro can any body suggest me that where i have to start.my Regard Mohd Moderator message: please search for available information/documentation/SCN pages and forums. Edited by

  • AIR Native Drag & Drop -- AIR app to Desktop

    Hello, I am trying to figure out how to drag from AIR app to dektop/MSWord. I found lots of sample for desktop to AIR app, but not vice versa. Is there any samples that I can have? How can I drag texts in a text area to desktop/MSWord? Thank you!!