Column in line to order by items problem

Hello
Version 10204.

I use function xmlagg in passes convert order lines.
SELECT *
from DBA_LOG_GROUP_COLUMNS
 WHERE table_name IN  ('NAP_CUST_USERS')
order by table_name   ,position ;

OWNER                          LOG_GROUP_NAME                 TABLE_NAME                     COLUMN_NAME                      POSITION LOGGING_PROPERTY
------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------- ------------------
PSSYS                          GGS_14831759                   NAP_CUST_USERS                 SETID                                   1 LOG
PSSYS                          GGS_14831759                   NAP_CUST_USERS                 COMPANYID                               2 LOG
PSSYS                          GGS_14831759                   NAP_CUST_USERS                 USERNAME                                3 LOG
PSSYS                          GGS_14831759                   NAP_CUST_USERS                 NAP_CLOSE_DATE                          4 LOG
PSSYS                          GGS_14831759                   NAP_CUST_USERS                 PERSON_ID                               5 LOG
Here is how I use this:
SELECT table_name ,
rtrim (xmlagg (xmlelement (e, column_name || ',')).extract ('//text()'), ',') enames
from DBA_LOG_GROUP_COLUMNS e
 WHERE table_name IN  ('NAP_CUST_USERS')
group by table_name
order by table_name;

NAP_CUST_USERS     SETID,COMPANYID,NAP_CLOSE_DATE,USERNAME,PERSON_ID
As you can see the order of the column in the second statement is different than in the first.
I like to keep the position of the column, because they are in the first statement.
Please note that there are several tables in the where clause.
Just to keep the example simple as possible, I have mentioned only one table

Thank you

How about using the clause ORDER BY of XMLAGG?
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb13gen.htm#ADXDB5084

SELECT table_name ,
RTRIM (XMLAGG (
  XMLELEMENT (E, COLUMN_NAME || ',')
  order by column_id
).EXTRACT ('//text()'), ',') ENAMES
FROM USER_TAB_COLS E
where table_name in ('EMP')
group by table_name

TABLE_NAME  ENAMES
----------- --------------------------------------------
EMP         EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO

Published by: stew Ashton on February 10, 2013 21:18

Tags: Database

Similar Questions

  • ORA-01785: ORDER BY item must include the number of an expression in the SELECT list

    Apex 3.1.1 Oracle 10g

    Hello
    I get this error message sporadically and finally understood how to reproduce the error constantly. The problem occurs in a standard report using the SQL query (body of function from PL/SQL returning SQL query). I found several other posts stating the same problem like this: Re: report sorting limitation

    My example on apex.oracle.com is here: [http://apex.oracle.com/pls/otn/f?p=23292:4:427533145943010:] with credentials of comments/example. Run the page 4. If you click on demo_customers and sort on credit_limit, and then click demo_users, you should get the error. If you click Debug, you will see the following text:
    0.06: show report 
    0.07: determine column headings
    0.07: activate sort
    0.07: parse query as: WFU_CARS
    0.07: query could not be parsed:
    select  * from DEMO_USERS
     order by 11,1
    failed to parse SQL query:
    ORA-01785: ORDER BY item must be the number of a SELECT-list expression
    It seems that the ORDER BY clause is not set to zero? refreshing? When the source of the report is changed. Note that sorting on demo_customers on the column credit_limit column 11. When executing the query of demo_users, an ORDER OF 11.1 is added to the SQL statement.

    Any ideas how to solve this problem? Thank you!

    Lisa

    Lisa:

    You can reset the current so specifications whenever you build a new query for the report area. Thus, in the pl/sql that generates the report query, add this line of code just before returning the query string.

    apex_util. REMOVE_SORT_PREFERENCES;

    CITY

  • Today, I can't change the order of items in the dock?

    Today, I tried to clean my dock and to rearrange the order that items appear.  Although I was able to delete icons I no longer need quick access, but I'm not able to rearrange the order in which they appear. I'd rather have those I use him more appear at the top of the docking station. I have my dock on the left side of my screen iMac 21.5 ". All the elements I want to rearrange are above this line, but they don't allow me to change the order in which they appear. In the past I have rearranged the icons, but not today. Help?

    There are ways to cause the dock must be blocked. keyboard shortcuts, maybe, but

    more are certainly the shortcuts of command-line or terminal. Some ideas of those who, here:

    • How to lock the size of the Dock, the Position and content in OS X - Mac...

    https://www.MacObserver.com/TMO/article/how-to-lock-the-Dock-size-position-and-c materials in os x

    August 28, 2015 - here are a few easy Terminal commands to lock station size, position,.

  • Microsoft SQL Server 2014 (SP1 - CU4) (KB3106660) query failed with error ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

    Hello
    I use Microsoft SQL Server 2014 (SP1 - CU4) (KB3106660) Enterprise Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1)

    SELECT DISTINCT A.PI_LOOKUP_CATEGORY_ID,
    REPLACE (REPLACE (UPPER (A.LOOKUP_CATEGORY_NAME), ' ', '_'), '-', '_') AS CATEGORY_TECH_NAME,
    A.LOOKUP_CATEGORY_NAME,
    A.LOOKUP_CATEGORY_DESCR,
    COUNT (B.PI_LOOKUP_CATEGORY_ID) AS USAGE_COUNT
    FROM [PI_LOOKUP_CATEGORY] A LEFT OUTER JOIN B [PI_INSIGHT_COLUMN] WE
    A.PI_LOOKUP_CATEGORY_ID = B.PI_LOOKUP_CATEGORY_ID
    A.PI_LOOKUP_CATEGORY_ID GROUP,
    REPLACE (REPLACE (UPPER (A.LOOKUP_CATEGORY_NAME), ' ', '_'), '-', '_').
    A.LOOKUP_CATEGORY_NAME,
    A.LOOKUP_CATEGORY_DESCR
    ORDER TO REPLACE (REPLACE (UPPER (A.LOOKUP_CATEGORY_NAME), ' ', '_'), '-', '_')

    above request is failed with error ' ORDER BY items must appear in the select list if SELECT DISTINCT is specified. " Microsoft SQL Server (SP1 - CU4) 2014 (KB3106660)

    same query works fine with older versions of SQL servers like (2008R2, or 2012)

    Please let me know the resolution of this problem...

    Thank you
    Touria

    Ask here:

    MSDN - SQL Server - Microsoft forums

  • Hello my MacBook Pro model (MacBook Pro (15 inch, early 2011 am Dubai bought the Sryalsh C02FD2CPDF8 number and I am in Iran that MacBook Pro not enter the device screen when I turned on the pink vertical lines can be seen, the problem is restless))

    Hello my MacBook Pro model (MacBook Pro (15 inch, early 2011 am Dubai bought the Sryalsh C02FD2CPDF8 number and I am in Iran that MacBook Pro not enter the device screen when I turned on the pink vertical lines can be seen, the problem is agitated and it is not difficult to work with him because I like and what I should I do?))

    Serial number C02FD2CPDF8V

  • Is it possible to change the order of items in the context menu of 'link' (I want to 'open in a new window... ("Be the first)?

    I did an upgrade FF v3.6.xx to v17.0.x and found that the order of items in the context menu 'Link' is not the same.
    v3.6 menu looks as follows: 1. "Open link in a new window", 2. "Open link in a new tab,"
    order of the items in menu v17.0 is 1 reverse. "Open link in a new tab", 2. " Open the link in a new window. "
    Position of all the other elements are uninteresting to me.
    How to exchange it two points higher in the contextual menu "link"?

    The two ways are useful:

    "Drag-n-drop" in the Editor window works.

    For my Windows XP path looks like: "C:\Documents and Settings\%account%\Application Data\Mozilla\Firefox\Profiles\%random_name%\chrome\userChrome.css".

  • How to query the total number of columns and lines filled with data?

    How to get the number of rows and columns in Exel file data using Excel report?

    Since you have posted this question in the forum of LabWindows/CVI, I guess you want to know how to do with CVI.

    You need to know how to open and activate the Excel data file.

    Depending on the function returns the total number of columns and lines col_count row_count, respectively.

    -----------------------------------------------------------------------------------------------------------------------------------------

    int CountColumnsAndRows (void)
    {
    Error HRESULT = 0;
    CAObjHandle rangeCurrentRegionHandle = 0;
    CAObjHandle rangeColumnsHandle = 0;
    CAObjHandle rangeRowsHandle = 0;
      
    unsigned long col_count = 0, row_count = 0;
      
    Must use the 'A1' property and CruuentRegion count the total of columns and lines, including the drafts!
      
    error = CA_VariantSetCString (& MyCellRangeV, 'A1');
      
    error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, & ExcelRangeHandle);
    If (error<0) goto="">
      
    error = Excel_GetProperty (ExcelRangeHandle, & ErrorInfo, Excel_RangeCurrentRegion, CAVT_OBJHANDLE, & rangeCurrentRegionHandle);
    If (error<0)  goto="" error="">
      
    error = Excel_GetProperty (rangeCurrentRegionHandle, & ErrorInfo, Excel_RangeColumns, CAVT_OBJHANDLE, & rangeColumnsHandle);
    If (error<0)  goto="" error="">
      
    error = Excel_GetProperty (rangeColumnsHandle, & ErrorInfo, Excel_RangeCount, CAVT_LONG, & col_count);
    If (error<0) goto="">
      
    error = Excel_GetProperty (rangeCurrentRegionHandle, & ErrorInfo, Excel_RangeRows, CAVT_OBJHANDLE, & rangeRowsHandle);
    If (error<0)  goto="" error="">
      
    error = Excel_GetProperty (rangeRowsHandle, & ErrorInfo, Excel_RangeCount, CAVT_LONG, & row_count);
    If (error<0) goto="">

    Error:

    CA_VariantClear (& MyCellRangeV);
    CA_VariantClear (& MyVariant);
    ClearObjHandle (& ExcelRangeHandle);
    ClearObjHandle (& rangeCurrentRegionHandle);
    ClearObjHandle (& rangeColumnsHandle);
    ClearObjHandle (& rangeRowsHandle);
      
     
    If (error<>
    ReportAppAutomationError (error);
      
    error return;
    }

  • I just ordered 14 items and I have an order confirmation, but when I go to download its says there is nothing in my account to download - help

    I just ordered 14 items and I have an order confirmation, but when I go to download its says there is nothing in my account to download - help

    PES 10, 11, 12, 13, 14 - https://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-downloads.html

  • Alphabetic or numeric order for items option?

    I am trying to create a view of 360 for a product, but when I import more than 1 image at a time I give myself the question where in the library, the files will be in alphabetical order but items are in an almost random order. This is causing issues in the creation of a 360 view due to not being in the right order. I have 100 images that must be imported, and I don't want to import each image one at a time for each product. Is there something that can be done if I can get all the items in good condition importer as in the library?

    adobe help01.png

    I reported this bug and it will be corrected in the next version. For this one, you are out of luck and have to move layers manually. If you had access to a version 2, you can load your images in there, save and re - open in version 3.0.

  • Display region report columns in the correct order

    I have a report of area in which the first 4 columns that are displayed are listed at the end of the section "column attributes.
    Why is this happening? Another setting must be done to make them display at the end, I would like to?

    Run the report.
    Click on the "Speed" control in the interactive report.
    Select the option "select columns".
    The top & arrows in the control as a result to arrange the columns in the desired order.
    Click 'apply '.
    Click on the "Speed" control in the interactive report.
    Select the option "save report".
    Save the report as the "default report settings"

  • convert a single column in lines

    Hi gurus,

    I have a GBA test table is id and name.

    Identification number
    name varchar2

    data are like

    name identity

    1 xy
    2 xyy
    3 mm
    4 pp

    Now my requirement is to convert the IDs of unique column in lines

    i, e my output should be Singel lines like:-1,2,3,4

    How to achieve this result.

    I have no idea to make this request.

    Please help guys.

    Thanks in advance.

    Vijay

    Oh, wait, now I see:

    I think that with clause will not work in this State

    You have not the clause at all.

    You can omit this part and change t in your own table name
    I only used it to generate sample data.
    That's why I commented :) - query real, based on the id is generated above: in the query, to indicate what is happening ;)

    As Alex has already pointed out:
    You only need the part from the line 7 (first example) or line 10 (second example)

    Hands a great coffee to Alex

  • IR - CubeQuery - no limit to the maximum number of columns or lines?

    In IR query processing cube, is there a limit to the maximum number of columns or lines? If so, how?

    When downloading of the results, are there limits to the maximum. lol the columns or lines as well?

    All documentation on its limits?

    Please help someone?

    Columns cannot be more than 256 upto Hyperion Interactive Reporting Studio 9.2.

    No, there is no limit to the maximum number of rows. It depends on the memory and available space on your machine.

    Please correct me if I'm wrong.

    I hope this helps.

    Kind regards

    Manmohan Sharma

  • How can I build a table using two digital controls and a button? Whenever I press the button, a column of 2 lines (digital orders) should be created.

    I tried several ways to date.

    I know that I can use the building to create a table of two numbers but I am not able to create a 2d in this way

    I also tried to use Replace subset of table, but still it won't work.

    I know that I have to use a table that has the index of the column starting with 0, so whenever I press the button of the column index incriments by 1 so the next column will change but I am not able to create this.

    You are the authority on what a Altenbach! He writes, I just did to make it work. Don't really consider this. Here's a modified version for the OP to use should he like:

  • Add line to pagination sorting tabular problem

    Hello

    I have a problem with a tabular presentation that has various sortable columns. If the user tries to add a line when the sort order is set to something where possibly NULL values are that appears first in the list, so the user cannot enter data (since the last results page still appears after clicking on the button Add a line).

    I know that the blank record is listed somewhere, since the number of pages in pagination is increased by 1, but it is impossible for the user to enter data on this issue since the passage home pages then deletes the empty record. How can I fix? Is it possible to programmatically reset all sort columns?

    See you soon!

    Hello

    Levels of sorting in the reports are stored as user preferences - it can be removed using PL/SQL. Take a look to: need to do the SORTING of columns only when I click on the column header and Re: placement works does not in reports of paging and default sorting

    Or, you can try adding an empty line in your SQL statement itself: problems with "add a line"

    Andy

  • CPHA does not suggest planned order for item used below Phantom

    Hi all

    We have an article buy which is used in the Nomenclature for a ghost.

    We do not get planned order is created for the item to buy it. We checked for SL, ASL and point level configuration for purchase that looks very good.

    Note - MRP_NEW_PLANNER_BACK_COMPATIBILITY is set to null which is equal to n

    Concerning

    Hello

    We have the question, the supplier that has been associated with the point to buy was not get collected in CPSA causing the problem

    In addition, we have raised SR with Oracle to find out why the provider is not get collected

    Concerning

Maybe you are looking for

  • Failed to read the configuration file. New installation on windows 7

    I just downloaded and installed firefox on my windows 7. No error on installation. When I try to launch Firefox I get this dialog box. Configuration - the configuration file cannot be read. Please contact your system administrator.

  • Best placement of router?

    My Airport Extreme is located on one side of my two-story home, in an office on the first floor. I have an Airport Express located downstairs, to the other side of the House.  My wifi coverage was uneven at the bottom. I recently read a study suggest

  • FIRST HP - problems with typing

    Hello, I have a HP first graphing calculator but I can't type more than 10 characters (letters, numbers or symbols) in any part of the calculator, weather, it is in the home, CASE or Notes view. How should I do? Sometimes I can cheat this bug and typ

  • Access Point WAP200 is compatible with the injector WAPPOE12?

    Hello!!! I want to bring the power of an Access Point WAP200. I need to know if the WAPPOE12 injector is compatible with this kind of Access Point.I deployed 108 AP WAP200 in a wireless network and I want to know what type of power injectors, I use i

  • Z5 camera flicker problem

    I noticed an intermittent random black line, touching the problem with the camera of my Z5... it happened only twice so far and remains alone on the screen for about 10 secons when the camera is first loaded up (not whenever). Flick essentially the b